Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java 19/20 swing apps window blank after unlocking screen

  1. #1
    Junior Member
    Join Date
    Aug 2023
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Java 19/20 swing apps window blank after unlocking screen

    I have a number of Java swing desktop apps that run continuously updating data. They monitor a number of sources in near real time.

    When using Java 18.0.2, I can lock my PC screen and when I unlock it the apps appear fine with all features visable and functional.

    I am starting to migrate my apps to either Java 19 or 20.

    When I change the desktop apps to Java 19 or 20, they function fine when PC screen is unlocked and update accordingly.

    But, if I lock my PC screen and then unlock it the app windows are all white and blank with no content at all. This does not occur with Java 18.0.2. I am not sure what I need to do to get them to maintain their content etc when using Java 19/20?

    Any suggestions please?

  2. #2
    Junior Member
    Join Date
    Aug 2023
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Java 19/20 swing apps window blank after unlocking screen

    I tried using multiple listeners to see if something got fired when the PC screen was unlocked but to no avail.

    SwingUtilities.invokeLater(() -> {
    elapsedTimeTextField.setText(actualTimeTakenTask);
    panel.repaint(); // this was added and it fixed the problem
    });

    I have the above code as part of a Timer instance that updates the textfield with elapsed time every second.

    The magic solution was to include the panel.repaint() line and that stopped the problem.

    Not sure why this fixed it but glad I stumbled upon it!!

    --- Update ---

    I tried using multiple listeners to see if something got fired when the PC screen was unlocked but to no avail.

    SwingUtilities.invokeLater(() -> {
    elapsedTimeTextField.setText(actualTimeTakenTask);
    panel.repaint(); // this was added and it fixed the problem
    });

    I have the above code as part of a Timer instance that updates the textfield with elapsed time every second.

    The magic solution was to include the panel.repaint() line and that stopped the problem.

    Not sure why this fixed it but glad I stumbled upon it!![/QUOTE]
    Last edited by pebuilder; August 27th, 2023 at 09:24 PM.

  3. The Following User Says Thank You to pebuilder For This Useful Post:

    Norm (August 28th, 2023)

Similar Threads

  1. Change JAVA Swing GUI Window in NetBeans
    By tazeunite00 in forum Java IDEs
    Replies: 4
    Last Post: August 29th, 2014, 02:12 AM
  2. Change JAVA Swing GUI Window in NetBeans
    By tazeunite00 in forum Java Theory & Questions
    Replies: 3
    Last Post: August 29th, 2014, 12:58 AM
  3. unable to full screen swing form on fedora
    By pradeep24 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 16th, 2014, 05:13 AM
  4. Replies: 2
    Last Post: March 2nd, 2014, 09:00 PM
  5. Blank screen on startup
    By CjStaal in forum Android Development
    Replies: 0
    Last Post: October 15th, 2012, 01:12 PM