I m using A BorderLayout
. In the north position I m having a panel called panNorth
, where I'm adding some component (say for one click I'm adding one button in the next row (gridlayout)). In the main frame in the center part I will add something later.
So what is my prob开发者_运维问答lem now is, when ever I'm adding new controls in panNorth
the size getting increased and occupy the BorderLayout's
center place. So I added a JScrollPane
in the north side and added the panNorth
in Jscrollpane, but nothing different happened. The same thing is happening again; the size of the JScrollPane
is expanding to the original size of the panNorth
so it displays all the components, the scrollbar is not use full now.
So please suggest to me how to make visible only 3 rows at a time.
Try using:
jScrollPane.setPreferredSize(new Dimension(panNorth.getWidth(), desiredHeight));
This should force the JScrollPane
to keep its preferred size in the North pane.
精彩评论