-
Enhancement
-
Resolution: Unresolved
-
P4
-
6
-
x86
-
windows_2000
J2SE Version (please include all output from java -version flag):
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
Does this problem occur on J2SE 1.4.x or 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Microsoft Windows 2000 [Version 5.00.2195]
JOptionPane has wrong Minimum Size
When using JDialog.setDefaultLookAndFeelDecorated(true) the dialog can only be resized to the buttons preferred size instead of it's minimum size.
The fix is to add a method to BasicOptionPaneUI called getMinimumSize(JComponent aComponent) that does the same as getPreferredSize except for it calls minimumLayoutSize instead of preferredLayoutSize.
1) Run Code
2) Try resizing the horizontal size of the dialog smaller than the buttons preferred size
import static javax.swing.JFrame.*;
import java.awt.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
JDialog dialog = new JOptionPane(new JButton("Test") {
public Dimension getPreferredSize() {
return new Dimension(600, 50);
}
public Dimension getMinimumSize() {
return new Dimension(100, 50);
}
}).createDialog(frame, "test");
dialog.setResizable(true);
dialog.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
Does this problem occur on J2SE 1.4.x or 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Microsoft Windows 2000 [Version 5.00.2195]
JOptionPane has wrong Minimum Size
When using JDialog.setDefaultLookAndFeelDecorated(true) the dialog can only be resized to the buttons preferred size instead of it's minimum size.
The fix is to add a method to BasicOptionPaneUI called getMinimumSize(JComponent aComponent) that does the same as getPreferredSize except for it calls minimumLayoutSize instead of preferredLayoutSize.
1) Run Code
2) Try resizing the horizontal size of the dialog smaller than the buttons preferred size
import static javax.swing.JFrame.*;
import java.awt.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
JDialog dialog = new JOptionPane(new JButton("Test") {
public Dimension getPreferredSize() {
return new Dimension(600, 50);
}
public Dimension getMinimumSize() {
return new Dimension(100, 50);
}
}).createDialog(frame, "test");
dialog.setResizable(true);
dialog.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}