try {
for (int i = 0; i < 148; i++) {
zx = zx+1;
if (zx==15) {
zx = 0;
zy = zy+1;
gbc.gridheight = zy;
} // end of if
gbc.gridwidth = zx;
JButton b = new JButton(champs[i]);
cp.add(b, gbc);
b.setName(champs[i]);
if (b.getModel().isPressed()) {
System.out.println(b);
} // end of if
}
} catch(Exception e) {
System.out.println(e);
}
I am trying to add an action/response to my 148 JButtons if they are pressed but it seems like I'm using the wrong if-clause. The layout works totally fine and all buttons are displayed in the right place with the right name but I can't add an action to them. I am still a java beginner so please keep that in mind. Any help is appreciated. Thanks in advance.