Using NetBeans Matisse to build a form with an array of JButtons

With Matisse I can build a form with a lot of buttons on it, but i want to use a 2-dim array of JButtons so that I can easily access the buttons. How should I do this?
[174 byte] By [PatrikChristela] at [2007-11-26 14:58:04]
# 1

Code it by hand. It's not that hard.

JButton [][]buttons = new JButton[NUM_ROWS][NUM_COLUMNS];

for (int row = 0; row < NUM_ROWS; row++) {

for (int row = 0; row < NUM_ROWS; row++) {

{

buttons[row][col] = new JButton();

// set other properties of buttons[row][col]

}

}

If there is a lot of stuff, you could even make a separate method for creating a single button:

private JButton createButton()

{

JButton button = new JButton();

// whatever else

return button;

}

Then, in the "for" loops:

buttons[row][col] = createButton();

doremifasollatidoa at 2007-7-8 8:46:52 > top of Java-index,Java Essentials,Java Programming...
# 2
Thx. Indeed, I know how I can code it by hand, but then I loose the efficiency of dragging and dropping components on my panels.I want to use Matisse because it's a lot easier than writing my own layoutmanagers.
PatrikChristela at 2007-7-8 8:46:52 > top of Java-index,Java Essentials,Java Programming...
# 3

I got around this by using the wysiwyg editor until I have as many components laid out as I can. It makes it easier to set up frames, set layouts, add components, etc. but you can't do everything with it. Then I copy the code out of the editor into my own file and make all the changes I need and finish it. In my experience you can't make useful guis with only editors, you will have to get your hands dirty with code (gasp!). There are just too many things you need to do that the editor doesn't understand.

hunter9000a at 2007-7-8 8:46:52 > top of Java-index,Java Essentials,Java Programming...