How to increase the width of a JComboBox?

0

How do I increase the width of a JComboBox in Java? The layout I'm using is as follows:

setLayout(new FlowLayout(FlowLayout.LEFT));
    
asked by anonymous 01.02.2014 / 03:26

2 answers

1

FlowLayout uses the preferred size of the component:

int largura = 100;
int altura = 21;
seuComboBox.setPreferredSize( new Dimension(largura,altura) );
    
01.02.2014 / 13:35
0

Try this.

comboBox.setMaximumSize( comboBox.getPreferredSize() );
    
01.02.2014 / 04:42