I have been having problems achieving the layout i want. My main panel is set to BorderLayout, i have a panel in the center and one on the left. This left panel is going to be a toolbox. I basically want the left panel to be 150px wide and simply have a column of buttons. I want each button to take up the whole 150px width. When the frame is resized and all of the buttons cant be displayed, i want a vertical scrollbar to appear.
I have tried using a toolContainer panel with FlowLayout, manually setting the preferred sizes of the buttons to 150px wide and setting the preferred size of the toolContainer to 150px width and 50px height (because im not really sure how many buttons i will have). This gives me the exact look im looking for, however, when i add a JScrollPane, because i've manually set the height of the toolContainer to a value, the scrolling doesnt kick in until the frame is less than the preferred height of the toolContainer. I'm not sure if this is the best method, but i tried setting up a loop that gets the height of all the components in the container and setting that as the preferred height and that seemed to work. So if there is a better way of creating this layout i'd love to know!!
But my main problem is that the scrollbars are acting very erratically. When the vertical scrollbar appears, it appears on the outside of the scrollpane (eg. there is 150px + width of the scrollbars), but then if i resize the frame just a little bit more, the scrollbar flicks to inside the panel (eg. width of container is 150px - width of scrollbars). Ideally i would always like the scrollbar to appear outside. Is there someway of controlling this?
I hope i've explained myself correctly!