Forums Register Login
aligning components
i created a class that extends JPanel, and added a JComboBox to it. i (hopefully) made them the same size like so:

i then have another JPanel with a 2X2 GridLayout with JLabels in the top row and StandardColorSelector's in the second row. the Jlables are left aligned , but the StandardColorSelector's are centered. i tried to left align them like so:
private StandardColorSelector backcolor = new StandardColorSelector();
private StandardColorSelector forecolor = new StandardColorSelector();
but it doesnt work
i also tried this:

and this:

[ February 16, 2004: Message edited by: Randall Twede ]
The problem is that the panels that hold the comboboxes are by default using FlowLayout, and FlowLayout by default is centered. You can change this by adding the line -

to StandardColorSelector's constructor.
thanks, thats what i needed. i set it outside the class, but it worked.

This thread has been viewed 1024 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 24, 2018 11:54:24.