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

  • SEARCH
  • Home
  • 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 839349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:27:01+00:00 2026-05-15T05:27:01+00:00

while my swing app is running I change the size of the screen (e.g.

  • 0

while my swing app is running I change the size of the screen (e.g. from 1024×768 to 800×600).

Is there any event I can listen to to be notified about this?

Alternatively I could check the screen size in every couple of second, but the Toolkit.getScreenSize() keeps telling me the old value.
How could I get the real screen size after the change?

Environment: Linux (tested on SuSE ES 11 and Ubuntu 9.04)

I appreciate your help.
Marton

  • 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-05-15T05:27:02+00:00Added an answer on May 15, 2026 at 5:27 am

    The following worked for me, but I’m on a Mac, so I can’t say for sure that it will work on Linux:

    System.out.println(GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getDisplayMode().getWidth() + "x" + GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getDisplayMode().getHeight());
    
    //Ignore this block, it was simply to give me a chance to change my resolution
    Scanner readUserInput=new Scanner(System.in);
    System.out.println("Waiting on input, go change your resolution");
    String myName=readUserInput.nextLine();
    
    System.out.println(GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getDisplayMode().getWidth() + "x" + GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getDisplayMode().getHeight());
    

    The output (blah is actually input) was as follows:

    1440x900
    Waiting on input, go change your resolution
    blah
    1280x960
    

    Obviously if you have multiple screen devices, you will have to exercise greater caution.

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

Sidebar

Related Questions

I haven't done any swing programming in a while, so I'm looking for some
I'm writing a small app with the help of Eclipse while learning Swing GUIs
To put it simple: a swing app that uses sqlitejdbc as backend. Currently, there's
While debuging a Swing application I saw this thread appear quite offen. There is
While I was reading Oracle Swing documentation, I came across this example of a
While I am searching for better method to exit a Swing Application in between
While my ASP.NET project uses version 3.5 of the framework , the event log
I've developed a desktop Swing app and I'm thinking about the best way to
I am getting NPE here: Color base = UIManager.getColor(inactiveCaptionBorder); while UIManager.setLookAndFeel(com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel); is set to
I have a Swing app, that I start using JNLP. When I start using

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.