I made a really simple test case:
- I have a global containing panel with a
BorderLayout(panel1) - This global panel contains a
JScrollPane(scroll1) - This
JScrollPanecontains a panel with aBoxLayoutset onPAGE_AXIS(panel2)
And then i have this little piece of code adding components (JLabel‘s) to the panel2:
for (int i = 0; i < 150; i++) {
panel2.add(new JLabel(String.valueOf(i)));
}
panel2.revalidate();
It works. Now i’d like to use a custom panel i’ve made that extends the JXPanel from SwingX. So panel2 looks like in my test case:
public class Panel2 extends JXPanel {
}
It does not work anymore. The scroll bar does not appear. Why? Is there anything special to do when using JXPanel within JScrollPane?
EDIT:
After using setScrollableHeightHint(ScrollableSizeHint.NONE); on panel2, panel2 resize itself regarding the number of components in it, this is not the behavior i want, i want the scroll pane to keep his fixed size.
Have a look at the scrollableHeightHint/scrollableWidthHint property of the JXPanel: it’s defaul is FIT, change to one of the modes which don’t (fill the viewport)