• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help needed with layout of buttons  RSS feed

 
pandu chinnu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam trying to create a frame with Menubar and Menuitems(which i have done successfully), next I want to create 9 buttons (3 rows and 3 coloums) on one half of the frame and a text area on the other half that displays results of the button events.

Please help me with the layout as Iam unable to get the buttons in position.(like those of calculator)...

Thanks
 
David Buzatto
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

You can use some combinations of layouts do create what you want, or use a IDE like netbeans, but if you really want to create your layout writing code, you can use:

In your main container (JFrame, etc) you can use a GridLayout with two columns. In witch column, you will add a JPane, or another container... For the left one, use use again the GriLayout (4 rows, 3 columns) e for the right one, you can use BorderLayout (the default for JPanel is FlowLayout) and add your text area in the center of if.

You can search for JGoodies Forms for a great layout manager.

There's lots of layout managers, including the new and extremamely cool GroupLayout added in Java 1.6.

I prefer to build my GUIs using NetBeans... Take a look http://www.netbeans.org

Bye!

[ July 13, 2007: Message edited by: David Buzatto ]
[ July 13, 2007: Message edited by: David Buzatto ]
 
pandu chinnu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi can you add one panel to another panel? U have said that one can add a gridlayout(0,2) to the JFrame(If I add that the position of my menubar goes haywire),,,,so I thought to add a panel1 to the main JFrame (with GridLayout(0,2)) and then add another panel2 to the first coloumn of the orginal panel1.(making the new panel gridlayout(3,3)) ,,,,,however

can you add a new panel to another panel?if so how? and also how do you specify(say there are 2 coloumns in panel1 per gridlayout) to add the new panel to the first coloumn?(Also should menubar be included in the panel or added directly to JFrame?


Please clarify.....Iam working on this for 2 days(I don't want to use any GUI buider - i have to hard code it).


Thanks.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> If I add that the position of my menubar goes haywire

it shouldn't.

here's a basic framework from your description

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!