Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8013255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:35:27+00:00 2026-06-04T19:35:27+00:00

I am a beginner int the JAVA language and is trying to learn how

  • 0

I am a beginner int the JAVA language and is trying to learn how to create full screen applications.

I am trying to create a simple application where when run, displays a full screen with blue back ground and a simple line of text in the center of the screen( it starts at position 400×300). The resolution of the application is set to 800×600.

I am running the code on a MacbookAir, running OSX Lion, with a screen resolution of 1440×900. The problem is, despite getting a blue background as I had expected, the text only appears on around upper left of the screen. The position of the text would continue to move down and right as I increase it’s position until it reaches beyond 1440×900 when it disappears. I am guessing that the screen resolution is still set at 1440×900 as oppose to 800×600.

Here are my main class:

import java.awt.*;
import javax.swing.JFrame;

public class bucky extends JFrame {
    public static void main(String[] args){

        DisplayMode dm = new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
        bucky b = new bucky();
        b.run(dm);
    }

    public void run(DisplayMode dm){
        setBackground(Color.BLUE); // Setting background color
        setForeground(Color.WHITE);
        setFont(new Font("Arial", Font.PLAIN, 24));

        //The Screen variable is going to be a screen object
        Screen s = new Screen();
        try{
            s.setFullScreen(dm, this); //this refers to whatever object we are working on, ie 's'
            try{
                //Once it is set to full screen, and wait for 5 second
                Thread.sleep(5000);
            }catch(Exception ex){};
        }
        finally{
            s.restoreScreen();
        }
    }

    public void paint(Graphics g){
        g.drawString("Test", 400, 300);
    }

}

And here is the the constructor for the Screen class and method from Screen class which sets the application to full screen

private GraphicsDevice vc; // Gives an interface to graphics card/video card.

public Screen(){
    //env is environment variable, containing all graphics manipulation objects
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();

    //When we get environment and getDegaultScreen Device, we get access to the entire monitor, not just a window
    vc = env.getDefaultScreenDevice();

}

public void setFullScreen(DisplayMode dm, JFrame window){ 

        window.setUndecorated(true); 
        window.setResizable(false); 
        vc.setFullScreenWindow(window); 


        if(dm != null && vc.isDisplayChangeSupported()) {
            try{
                vc.setDisplayMode(dm); 
            }catch(Exception ex){}
        }

    }

If anyone could point me out to why the resolution is not being set properly, it would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:35:29+00:00Added an answer on June 4, 2026 at 7:35 pm

    From the docs for setDisplayMode

    The display mode must be one of the display modes returned by
    getDisplayModes(), with one exception: passing a display mode with
    DisplayMode.REFRESH_RATE_UNKNOWN refresh rate will result in selecting
    a display mode from the list of available display modes with matching
    width, height and bit depth.

    So you’ll need to make sure that you set the display mode to one of those.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP beginner working from a tutorial. I'm trying to do a simple upload from
Am Beginner to java.I have a small doubt while i am developing an application
I am still a beginner in java and I am attempting to create a
I'm beginner in Java Android developing. I'm using Eclipse SDK 3.6.1 version. I'm trying
I am a beginner in java programming. I am trying to recreate a simplified
This is not homework. I am a beginner (novice) java programmer, trying to read
I am Java beginner and I am trying to code something. Currently I am
I'm beginner in Java, I'm trying to compile some small program, can somebody explain
I am beginner to Apache POI api. I am trying to create excel sheet
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.