-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
ingrid.yao@Eng 2001-05-10
J2SE Version (please include all output from java -version flag):
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b62)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b62, mixed mode)
Does this problem occur on J2SE 1.3? Yes / No (pick one)
No. (it happens since Merlin build 10)
Operating System Configuration Information (be specific):
Win2k,Linux and Solaris as well.
Hardware Configuration Information (be specific):
all
Bug Description:
There is a problem with the metal and Windows and Motif combobox plafs.
The minimum size of a combox grows by the insets every time a change of an
object in the combobox is signalled using fireContentsChanged().
This problem is caused by returning the private value cachedDisplaySize in
javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize() which is modified by
the caller (getMinimumSize() in javax.swing.plaf.metal.MetalComboBoxUI and
alike in the Windows plaf) and thus changed accidently..
Test program:
+++++++++++++++++
/**
* Test case which demonstrates the JDK 1.4 combobox size bug.
*/
import javax.swing.*;
public class ComboBoxTest
{
/**
* This method is called after start up.
*/
public static void main(String[] args)
{
MyComboBoxModel model = new MyComboBoxModel();
JComboBox box = new JComboBox(model);
model.addElement("foo");
model.addElement("bar");
for(int i=0;i<10;i++)
{
model.fireContentsChanged(new Object(),1,1);
System.out.println("minimum size "+i+": "+box.getMinimumSize());
}
System.exit(0);
}
private static class MyComboBoxModel extends DefaultComboBoxModel
{
/** Overriden to be public. */
public void fireContentsChanged(Object source, int index0, int index1)
{
super.fireContentsChanged(source,index0,index1);
}
}
}