Heavyweight Component resizing inside JScrollpane
Hi,
in my application i have a heavyweight component (jpanel with a few buttons, jtextfields, jtextareas, etc) that i put in a scrollpane.
the scrollpane is supposed to only scroll vertically - in the horizontal direction, i want to resize the components in the scrollpane to the appropriate size depending on the main frame of the application.
when the application starts, everything is fine and the components take up the available size.
when i increase the application window size hotizonally, the components (mainly the jTF and jTA) increase in size, as it is's supposed to be.
But once i decrease the horizontal size again, the jTF and jTA stay the size they were before and do not shrink as i want them to.
If i just add the jpanel without putting it inside a jscrollpane, the resizing works perfect. i need a vertical scroller though, so this is not an option.
here is a picture that shows the resizing behaviour:
http://img3.imagebanana.com/img/5wa79nw1/Untitled2.jpg
inside the JPanel that is inside the scrollpane i use a grouplayout.
here is a portion of my code that shows how one of the components inside the panel is layed out.
Code:
// component layout for the LINKS panel
// horizontal groups
SequentialGroup hGroup = layout.createSequentialGroup();
ParallelGroup h2 = layout.createParallelGroup();
ParallelGroup h3 = layout.createParallelGroup();
ParallelGroup h4 = layout.createParallelGroup();
h2.addComponent(linkListScrollPane, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE);
h3.addComponent(bAddLink);
h4.addComponent(bRemoveLink);
hGroup.addGroup(h2);
hGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED);
hGroup.addGroup(h3);
hGroup.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED);
hGroup.addGroup(h4);
layout.setHorizontalGroup(hGroup);
// vertical groups
SequentialGroup vGroup = layout.createSequentialGroup();
ParallelGroup v1 = layout.createParallelGroup();
v1.addComponent(linkListScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE);
v1.addComponent(bAddLink);
v1.addComponent(bRemoveLink);
vGroup.addGroup(v1);
layout.setVerticalGroup(vGroup);
If other code portions are needed, please tell me.
I hope someone can help me with this one :)