Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JFrame freezes on Windows 8.1 when resized

Also posted on coderanch.com.

import javax.swing.*;

public class Tmp {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JFrame frame = new JFrame();
                frame.setSize(200, 200);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.add(new JTextField());
                frame.setVisible(true);
            }
        });
    }
}

A problem regarding resizing this JFrame.

This is how it looks by default right after program starts:

enter image description here

When I try to resize it like shown on a picture and move a mouse pointer to the top of a screen (like on picture below) I see this:

enter image description here

When I release the mouse the frame is resized but unresponsive. And there is a black space on it. This is how it looks:

enter image description here

This happens on Windows 8.1 and java 1.7.0_45 (it also happens on Windows 7).
The problem does not occur when using other ways of resizing a frame in Windows.
It only happens when "Show window contents while dragging" is active in system settings.
Why is it happening?
How can this be fixed?

like image 407
Pawel P. Avatar asked Dec 14 '13 12:12

Pawel P.


People also ask

How do I stop JFrame from resizing?

Making a Frame Non-Resizable: use setResizable(false) to freeze a frame's size. : JFrame Window « Swing « Java Tutorial.

Which method is used for resizing the frame in Java?

To resize a frame, There is a method JFrame. setSize(int width, int height) which takes two parameters width and height.


1 Answers

This sounds a lot like the bug reported here. Supposed to be fixed in JDK8 and 9, and according to the issue tracker the bug fix is backported into version 7u80.

like image 67
Robin Avatar answered Oct 09 '22 16:10

Robin