This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes grouplayout design and buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "grouplayout design and buttons" Watch "grouplayout design and buttons" New topic
Author

grouplayout design and buttons

Yashwanth Raj
Greenhorn

Joined: Jan 18, 2013
Posts: 18
hi i m new to gui in java.i am programming tictactoe game.for that i will need 9 buttons of order3x3.but how can i do it with grid layout class.i cant even set 4 buttons of correct order.please help
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1973
    
    7

Are you using GridLayout or GroupLayout (as the title suggest)? For GridLayout, the constructor should be as easy as new GridLayout(3,3).


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9993
    
    7

GroupLayout is designed for DnD style UI builders. I would strongly recommend staying away from DnD UI builders.

Like K. Tsang correctly pointed out check out the API docs for GridLayout. It even has a working example.
In case you run int trouble, post your SSCCE code here so we can help point you in the right direction.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Yashwanth Raj
Greenhorn

Joined: Jan 18, 2013
Posts: 18
sorry .it is grid layout.and not grouplayout.but when i use 'grid layout' the buttons are well arranged of order 3x3.but when i add a menu bar,it also becomes like a cube rather than like a bar on the top next to the title bar.i tried both grid and group layouts.but group layout is too complex.so is there any other layouts to arrange the buttons of order 3x3 without affecting the menubar?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9993
    
    7

Maneesh Godbole wrote:In case you run int trouble, post your SSCCE code here so we can help point you in the right direction.

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1973
    
    7

Yashwanth Raj wrote:sorry .it is grid layout.and not grouplayout.but when i use 'grid layout' the buttons are well arranged of order 3x3.but when i add a menu bar,it also becomes like a cube rather than like a bar on the top next to the title bar.i tried both grid and group layouts.but group layout is too complex.so is there any other layouts to arrange the buttons of order 3x3 without affecting the menubar?


Are you setting the layout for the entire frame as GridLayout or just a Panel when the buttons go.

By default the JFrame default layout is BorderLayout.
Yashwanth Raj
Greenhorn

Joined: Jan 18, 2013
Posts: 18
i m setting the layout for just the panel where the buttons go .the order should be 3x3.and i also want the menu bar on top for menus like game start and game exit
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9993
    
    7

Yashwanth Raj wrote:... i also want the menu bar on top for menus like game start and game exit

Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html
Yashwanth Raj
Greenhorn

Joined: Jan 18, 2013
Posts: 18
thank you.now i am done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: grouplayout design and buttons
 
Similar Threads
GUI
Receiving a value from servlet
WA #1.....word association
tuna hot dish
an array of buttons in an applet ?