Resizing components inside of JScrollPane

Hello,

I need help with getting components to resize properly in side of JScrollPane based on the width of the main panel.

Here is what I got:

a JPanel mainPanel is added to JScrollPane.

Now I need to add n number of rows to main panel, with each raw containing 3 square panels (sqPanel) in such way that initial dimension of each panel will be 1/3 of viewable applet width so there is no horizontal scrolling.

Here is an example:

[+] [+] [+]

[+] [+] [+]

.

n

.

[+] [+] [+]

If mainPanel is resized sqPanel has to be resized accordingly and this is where I am getting stuck.

Any tips, references or code outlines would be much appreciated.

Kind regards

[741 byte] By [Corwin120a] at [2007-11-26 22:54:48]
# 1
add a component listener to your main panel.
kloebera at 2007-7-10 12:18:51 > top of Java-index,Desktop,Core GUI APIs...
# 2
Hi kloeber,Can you please be more specific. I'm not sure what you have in mind.ThanksDmitri
Corwin120a at 2007-7-10 12:18:51 > top of Java-index,Desktop,Core GUI APIs...
# 3
> with each raw containing 3 square panels (sqPanel) in such way that > initial dimension of each panel will be 1/3 of viewable applet width [url http://java.sun.com/docs/books/tutorial/uiswing/layout/grid.html]How to Use Grid Layout[/url]
camickra at 2007-7-10 12:18:51 > top of Java-index,Desktop,Core GUI APIs...
# 4
add a component adapter to your main panel. if it is resized, you get a trigger and recalculate the sizes of your sqPanelsoruse a GridBagLayout as camikr suggestedorwhy not use a JTable which recalculates the column width automaticallythomas
kloebera at 2007-7-10 12:18:51 > top of Java-index,Desktop,Core GUI APIs...