views:

413

answers:

2
JPanel pMeasure = new JPanel();
....
JLabel economy = new JLabel("Economy");
JLabel regularity = new JLabel("Regularity");
pMeasure.add(economy);
pMeasure.add(regularity);
...

When I run the code above I get this output:

Economy Regularity

How can I get this output, where each JLabel starts on a new line? Thanks

Economy  
Regularity
+4  A: 
John Kugelman
A: 

A quick way is to use html within the JLabel. For instance include the <br/> tag.

Otherwise, implement a BoxLayout.

waqasahmed