• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

grouplayout design and buttons

 
Yashwanth Raj
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3508
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using GridLayout or GroupLayout (as the title suggest)? For GridLayout, the constructor should be as easy as new GridLayout(3,3).
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yashwanth Raj
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3508
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.now i am done
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic