Name: rk38400 Date: 05/20/98
Setting the first JComboBox item to null results
in a bad computation of the height for the following
items. I was really expecting the null string "" to
behave like a space string " ". Here's a sample
to duplicate the problem.
----------------- cut here ----------------
//
// Test case for JComboBox. Setting a null string "" results in an
// inaccurate combo item height computation.
//
//
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame
{
public Test()
{
setTitle("JComboBox test");
setLocation(400, 100);
setSize(300, 200);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
Container c = getContentPane();
c.setLayout(new GridLayout(5,1));
c.setBackground(Color.lightGray);
JComboBox combo = new JComboBox();
combo.addItem(""); // This is causing the problem
combo.addItem("Second");
combo.addItem("Third");
c.add(combo);
}
public static void main(String args[])
{
Test test = new Test();
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception e) {
e.printStackTrace();
}
test.show();
}
}
(Review ID: 30833)
======================================================================