I use BorderLayout one a InternalFrame to arrange three components: JPanel (North), JTree (West) and JTable (East). My problem is the size and location of the JTable. I used setPreferredSize() and setLocation() but none of them seems work properly. The size is not what I set and the location changes when I drop the InternalFrame. Have you had any similar experience and want to share?
"To err is human, but to really foul things up you need a computer." Paul Ehrlich.
BorderLayout ignores many of the preferred/max/min dimensions of the components it manages. As the Javadoc says,
The components are laid out according to their preferred sizes and the constraints of the container's size. The NORTH and SOUTH components may be stretched horizontally; the EAST and WEST components may be stretched vertically; the CENTER component may stretch both horizontally and vertically to fill any space left over.
Also, since JTable really works the best in a JScrollPane, some of these methods should be applied to the JScrollPane rather than the JTable. JTable also supplies a method with a really long name that helps a lot when dealing with preferred size issues - setPreferredScrollableViewportSize(). Basically, this method tells the scroll pane what size it needs to be when it contains this table. I usually calculate the Dimension passed into it off of the table's column and row sizes.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.