• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't add anymore components to one of my panel

 
harry lynn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

This is my very first post and just wanna say to hi everyone first. I'm writing a GUI tic-tac-toe game for my skool assignment using MVC. It's a pain in the neck. I'm having a problem regarding to my game board creation. I've shown the code below. The board works fine but just next 2 the board, there are 2 buttons and 2 labels. New Game button followed by Undo button and followed by Message which shows who turn it's and the last component is to show Who win the game. The problem is I can't add anymore buttons in my "secondColumnPanel". I've attached the window which i'm trying to achieve. Please any suggestion would be very much appreciated. Thanks everyone.

tic_tac_toe.jpg
[Thumbnail for tic_tac_toe.jpg]
This is what i'm trying to do
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's your code (stripped of unrelated stuff), which works OK (adding an extra 2 JLabels)
with the making of newGameButton and undoGameButton as new JButton()s (don't have access to NewGame() or Undo())



perhaps the problem is related to the what is returned from newGame.getButton() and undoGame.getButton(), but it's only a wild guess

try changing newGameButton and undoGameButton as I did, and see if you can add extra components>
 
harry lynn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply. Yeah, it works fine now. I dunno what went wrong. I been trying to add 2 more components since this evening and those 2 just didn't show up. . Sorry for being stupid again but I still have another question. How can i put some space between my first panel and second panel ?? It just doesn't look so good. Please help me out of this again and thz millions in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> How can i put some space between my first panel and second panel ??

defaultWindow.setLayout(new GridLayout(0,2));

use the 3rd/4th parameters as you've done here
secondColumnPanel=new JPanel(new GridLayout(4,10,30,30));
 
harry lynn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot ! It solved
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic