posted 12 years ago
I have spent the day touring layouts trying to achieve the following-
Three buttons in a vertical row
All the same width
The size of the buttons do not change when I resize the container
The buttons stay at the top of the container
With gridlayout, the buttons are the same size, but they resize when I change the container size
With boxlayout, the buttons keep their size and stay at the top of the container, but they are all different widths
With gridbaglayout, the buttons are all the same width, and keep there size, but move to the center of the container on resizing.
Having read what I could, I thought setting anchor would keep them pinned to the top of the container, but this is not working.
I am placing the JPane with the buttons (that I want to stay at the top) and a JScrollPane with a table in it, into another Jpanel. The buttons are WEST and the table is CENTER. That does what I want in the sense that the button panel does not get any wider when I resize and the table nicely resizes in height and width. So I don't want to break that behavior. I just want those buttons to stay at the top. The table does!
I suspect I am missing something simple. Can someone explain this to me?