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:
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:
When I release the mouse the frame is resized but unresponsive. And there is a black space on it. This is how it looks:
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?
Making a Frame Non-Resizable: use setResizable(false) to freeze a frame's size. : JFrame Window « Swing « Java Tutorial.
To resize a frame, There is a method JFrame. setSize(int width, int height) which takes two parameters width and height.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With