There is a common issue on every Swing application I wrote: black area appears when resizing window, even for the simplest code below:
import javax.swing.*;
public class SampleWindow extends JFrame {
public static void main(String[] args) {
SampleWindow sampleWindow = new SampleWindow();
sampleWindow.setTitle("Sample Window");
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
contentPane.add(new JLabel(
System.getProperty("os.name") + " Java " + System.getProperty("java.version")
), BorderLayout.CENTER);
sampleWindow.setContentPane(contentPane);
sampleWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
sampleWindow.setSize(400, 200);
sampleWindow.setVisible(true);
}
}
And let's see what JavaFX acts:
Is there any way to eliminate this?
I'm tring to add a component listener and print when event comes:
sampleWindow.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
System.out.println("Resizing event: " + System.currentTimeMillis());
}
});
I got these output:
Resizing event: 1614328759426
Resizing event: 1614328759524 // huge delay
Resizing event: 1614328759525
Resizing event: 1614328759525
Resizing event: 1614328759525
Resizing event: 1614328759525
Resizing event: 1614328759525
Resizing event: 1614328759526
Resizing event: 1614328759526
It is obvious that there is a huge delay between first line and second line. I think trying to handle resizing event is no effort.
I've found even IntelliJ also has a similar issue, so alright I give up :(




