-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
7
-
generic
-
windows_2000
Debugging application shows that there is a Component.hide() invocation happen on startup:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1295)
at java.awt.Component.hide(Component.java:1481)
at java.awt.Component.show(Component.java:1458)
at java.awt.Component.setVisible(Component.java:1408)
at javax.swing.JComponent.setVisible(JComponent.java:2622)
at javax.swing.JRootPane.createGlassPane(JRootPane.java:547)
at javax.swing.JRootPane.<init>(JRootPane.java:365)
at javax.swing.JFrame.createRootPane(JFrame.java:278)
at javax.swing.JFrame.frameInit(JFrame.java:259)
at javax.swing.JFrame.<init>(JFrame.java:226)
at UnneededHide.main(UnneededHide.java:6)
That occur because the GlassPane class has invisible state assigned by default. That time Component.hide() has only "if (visible)" check in it so the first hide() call passes it.
import java.awt.*;
import javax.swing.*;
public class UnneededHide extends JFrame {
public static void main(String [] args) {
JFrame f = new JFrame("JSwing");
f.add(new JButton("HI!"));
f.pack();
f.setVisible(true);
}
}
There is one more place that forces the Component.hide() method to happen on startup. If a ScrollPane is used within the application, then the ScrollPaneLayout.layoutContainer() forces the hide() method for JScrollBar if there is no need to show it up. Unfortunately, that happen after the peer has been created.
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1295)
at java.awt.Component.hide(Component.java:1481)
at java.awt.Component.show(Component.java:1458)
at java.awt.Component.setVisible(Component.java:1408)
at javax.swing.JComponent.setVisible(JComponent.java:2622)
at javax.swing.JRootPane.createGlassPane(JRootPane.java:547)
at javax.swing.JRootPane.<init>(JRootPane.java:365)
at javax.swing.JFrame.createRootPane(JFrame.java:278)
at javax.swing.JFrame.frameInit(JFrame.java:259)
at javax.swing.JFrame.<init>(JFrame.java:226)
at UnneededHide.main(UnneededHide.java:6)
That occur because the GlassPane class has invisible state assigned by default. That time Component.hide() has only "if (visible)" check in it so the first hide() call passes it.
import java.awt.*;
import javax.swing.*;
public class UnneededHide extends JFrame {
public static void main(String [] args) {
JFrame f = new JFrame("JSwing");
f.add(new JButton("HI!"));
f.pack();
f.setVisible(true);
}
}
There is one more place that forces the Component.hide() method to happen on startup. If a ScrollPane is used within the application, then the ScrollPaneLayout.layoutContainer() forces the hide() method for JScrollBar if there is no need to show it up. Unfortunately, that happen after the peer has been created.