Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BorderLayout & FlowLayout

 
Shane Lilly
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic