Hi, I know the difference between the two layouts in the title, that FlowLayout adds onjects onto the canvas one after each other in a line from left to right, then taking a new line when the edge of the canvas is reached. Also that BorderLayout can be set to the NORTH, SOUTH, EAST, WEST and CENTER of the canvas. What I'm having trouble with is getting them to do what it is I'm after! I want to have a column of buttons on the left of the canvas, the column only being one button wide. Then the rest I want to use to draw on, i.e. like a user menu on the left and then when buttons are pressed they are drawn on the main part of the canvas (the right section). Can anyone help me do this? I've been playing obout with the Layouts for ages, and just end up going round in circles! Thanks
Joined: Feb 20, 2004
Sorry, just reading over that, I will make it a little clearer! I want two panels, one on the left of the container, and one on the right. The one on the left I want for the buttons, so that the buttons are displayed one under the other. Thanks again!
You can do this with GridBagLayout, but I think it's easier to understand to just use multiple panels with different layouts.
It sounds like what you want is a Panel with BorderLayout at the top level (the content pane of the JFrame has this by default). Create another panel with GridLayout( 0, 1 ) and add all the buttons to it. Add the new panel to the top panel using BorderLayout.WEST. Create your text area and add it to the top panel using BorderLayout.CENTER.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.