Skip to main content

JComboBox Rendering Regression on Win XP

No replies
swpalmer
Offline
Joined: 2003-06-10
Points: 0

Apparently it's tricky to get the width of a combobox right.

Bug #4966585 is back again... just tested with build 88.

<br />
import java.awt.BorderLayout;</p>
<p>import javax.swing.JComboBox;<br />
import javax.swing.JFrame;<br />
import javax.swing.JLabel;<br />
import javax.swing.JPanel;<br />
import javax.swing.UIManager;<br />
import javax.swing.UnsupportedLookAndFeelException;</p>
<p>/*<br />
 * Created on 16-Jun-2006<br />
 *<br />
 */</p>
<p>public class ComboTest<br />
{<br />
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException<br />
	{<br />
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());<br />
		JFrame f = new JFrame("Windows XP LnF - ComboBox Width Test");<br />
		JComboBox cb = new JComboBox(new String [] {"Video + Audio", "Video only", "Audio only"});<br />
		JPanel p = new JPanel();<br />
		p.add(cb);<br />
		f.getContentPane().add(p, BorderLayout.NORTH);<br />
		f.getContentPane().add(new JLabel("The above combox is sized too narrow on Java 6 and cuts off the text of the first item.  Java 5 does not have the problem."), BorderLayout.SOUTH);<br />
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br />
		f.pack();<br />
		f.setVisible(true);<br />
	}</p>
<p>}<br />