-
Bug
-
Resolution: Fixed
-
P3
-
1.1.6, 1.2.0
-
1.2.2
-
x86
-
windows_nt
With BoxLayout, if a Component's minimumSize is larger than its preferredSize, when the window is packed one dimension receives the minimumSize, while the other dimension receies the preferredSize.
Run the following application, and you'll see that the oval's drawn with a width larger than it should be.
Having the minimumSize larger than the preferredSize is highly atypical, but it should still behave reasonably.
//------------------------SizeTest.java------------------------------
import java.awt.*;
import com.sun.java.swing.*;
//import java.awt.swing.*;
public class SizeTest
{
static public void main(String args[])
{
JDialog dialog = new JDialog();
Container pane = dialog.getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
pane.add(new XComponent());
dialog.pack();
dialog.show();
}
}
class XComponent extends JComponent
{
public Dimension getPreferredSize() {
System.out.println("getPreferredSize");
return new Dimension(150,150);
}
public Dimension getMinimumSize() {
System.out.println("getMinimumSize");
return new Dimension(200,200);
}
public void paintComponent(Graphics g) {
Dimension d = getSize();
g.drawOval(0,0,d.width-1,d.height-1);
}
}
Run the following application, and you'll see that the oval's drawn with a width larger than it should be.
Having the minimumSize larger than the preferredSize is highly atypical, but it should still behave reasonably.
//------------------------SizeTest.java------------------------------
import java.awt.*;
import com.sun.java.swing.*;
//import java.awt.swing.*;
public class SizeTest
{
static public void main(String args[])
{
JDialog dialog = new JDialog();
Container pane = dialog.getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
pane.add(new XComponent());
dialog.pack();
dialog.show();
}
}
class XComponent extends JComponent
{
public Dimension getPreferredSize() {
System.out.println("getPreferredSize");
return new Dimension(150,150);
}
public Dimension getMinimumSize() {
System.out.println("getMinimumSize");
return new Dimension(200,200);
}
public void paintComponent(Graphics g) {
Dimension d = getSize();
g.drawOval(0,0,d.width-1,d.height-1);
}
}