• Post Reply Bookmark Topic Watch Topic
  • New Topic

Netbeans GUI creator with border and gridbag layouts?  RSS feed

 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm trying to use netbeans GUI creator to create a chessprogram. However, the default "freeflow" layout is very difficult to work with. However, when I switch the layout to gridbag or border layout, I can't figure out really how to do anything. I don't know how to resize or position elements. Is there something simple I'm missing, or can someone direct me to a good set of tutorials for using netbeans GUI creator with non standard layouts?

(I originally used absolute layout, which I can easily add and position elements in, but which I abandoned because i want the chessboard squares to resize when the window changes size).
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pleased to see you abandoned absolute positioning.
I always thought the NetBeans GUI builder defaulted to group layout. I suggest you either use grid bag layout or the GUI builder, but you can't use both. For a chessboard, I presume you are using a 64‑element array (or an 8×8 array‑of‑arrays), so you can add all the squares in a loop, which I do not believe you can do with the GUI builder.

I shall move this discussion to our GUIs forum.
 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you're saying there's no way to use the GUI builder with the grid bag layout? I certainly can't figure out how, but it seems like there should be a way since netbeans has an option for switching the layout to grid bag.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't know about that option. I think you should either use a GUI builder or decide which layout to use. If you want to specify details, write the code by hand. And also find out about Cai Horstmann's GBC class before trying anything with GridBag.
Create a factory method for making chess square objects and run it 64× and add the squares to a panel, which you can put a border on.
 
K. Tsang
Bartender
Posts: 3632
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For populating the squares, can't the panel use BoxLayout or GridLayout to do job? I don't see why you need to use GridBagLayout.

For putting the chess piece in the square.... the default JPanel layout (FlowLayout) should do because you only have a single item/object.
 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the problem is that I'd like to add a text field that says when theres check or checkmate, and a list that lists all the moves in the game. So maybe I don't need grid bag layout specifically, but the real question is whether or not theres a way to use the netbeans GUI builder with non standard layouts.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!