wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Can't add anymore components to one of my panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can Watch "Can New topic
Author

Can't add anymore components to one of my panel

harry lynn
Greenhorn

Joined: Feb 26, 2009
Posts: 3
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.




[Thumbnail for tic_tac_toe.jpg]

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Feb 26, 2009
Posts: 3
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Feb 26, 2009
Posts: 3
Thanks a lot ! It solved
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't add anymore components to one of my panel