File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes BorderLayout & FlowLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "BorderLayout & FlowLayout" Watch "BorderLayout & FlowLayout" New topic
Author

BorderLayout & FlowLayout

Shane Lilly
Greenhorn

Joined: Feb 20, 2004
Posts: 18
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
Shane Lilly
Greenhorn

Joined: Feb 20, 2004
Posts: 18
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!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Here's something to play around with.
(I've only just started tinkering with GridBagLayout,
so there might be better ways of doing it)
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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.



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
 
subject: BorderLayout & FlowLayout