Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

BorderLayout & FlowLayout

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic