My first question would be, why do you have 3 canvas' on 3 JPanels that are placed on a parent JPanel. It seems like the 3 JPanels could just be omitted. They seem like an extra component you don't need?
With that being said, I'm not real clear yet on the layout you are needing. You seem to be using a BorderLayout and when putting components N, CENTER, and S, the center component will be larger than the N and S components.
If you just want to line up 3 components vertically, take a look at either a BoxLayout or GridLayout.
You mention using canvases; I would use a JPanel instead of a Canvas — mixing Swing and AWT components can give undesirable results.
One of the problems of using a BorderLayout is that the North and South sections will need some component vertical size information to properly display your components. They expand the components to fill the horizontal space. This can get messy. If you know the height you want for the North and South components you can do
Assuming all three graphic components are to be the same size you could try GridLayout (as Gregg recommends above) or a GridBagLayout. Here's a demo of those two:
Joined: Sep 29, 2004
GridLayout (3,2) seems to be yielding some better results.
It's also introduced some, but I think they are more easily explained here.
Check out this code fragment:
This is placing one of my canvases on the tabbedPane, but it has the side affect of making my button the same height as my canvas. Do I have to specifically set the size of that button to get around that problem?
Joined: Jan 14, 2004
GridLayout ignores the preferred size of the components you hand it and tries to display all of its components at the same size. To keep the button at its preferred size you can add it to a JPanel and add the JPanel to the GridLayout (or BorderLayout). The JPanel will expand to fill the grid cell and allow the JButton to remain at its preferred size. The general practice in Swing is to use the JComponent methods get/setPreferredSize in lieu of setSize.
Joined: Sep 29, 2004
OK, I'll give the button on a Panel a try.
I've changed from Canvases to panels and that has also cleared up some of my problems.
I was seeing the canvases appear drawn overtop of other components and I was assuming that it must be happeneing because of the order in which I was creating the components.
However, like I said above, as soon as I switch to JPanels in place of the Canvases, that problem went away.