Hey everybody,
I've encountered a weird problem when we moved our application
from 1.4.2 to 1.5. For some reason, when we open a modal dialog
box and set the initial size using pack(), the modal dialog box will
fill the screen horizontally, but only sometimes. I traced the code
from setVisible(true) to the peer, and what followed were a bunch of
ComponentEvents which lead to the dialog box expanding from the
packed size.
I created a simple test case, which is attached. The odd thing is it
works for the most part, but every now and again, the modal
dialog box will expand horizontally to fill the entire screen. I've been
able to reproduce it clicking the button and closing the window
around 25 times.
I'm running this on RHEL WS release 3 using Java version 1.5.0_07-b03 64-bit, mixed-mode.
Does this happen for anyone else, or am I just nuts?
Thanks for any assistance you can provide.
Regards,
Duke
public class ModalityTest {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
javax.swing.JFrame appFrame = new javax.swing.JFrame(
"Modality Test");
final javax.swing.JDialog modalDialog = new javax.swing.JDialog(
appFrame, "Modal Dialog", true);
modalDialog.getContentPane().add(new javax.swing.JLabel(
"Modal Dialog"));
modalDialog.setDefaultCloseOperation(
javax.swing.JDialog.DISPOSE_ON_CLOSE);
modalDialog.pack();
appFrame.setDefaultCloseOperation(
javax.swing.JFrame.EXIT_ON_CLOSE);
javax.swing.JButton button = new javax.swing.JButton("Test");
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent ev) {
modalDialog.setVisible(true);
}
});
appFrame.getContentPane().add(button,
java.awt.BorderLayout.CENTER);
appFrame.pack();
appFrame.setVisible(true);
}
});
}
}