G
Guest
Hi all,
I have an AWT problem. I'd like to add some Buttons to a Panel (with a
GridLayout of
dynamic dimension). Practically when I click on button1 it should
happens this:
void button1_actionPerformed(ActionEvent e) {
int n=4;
this.gridLayout1.setRows(n);
this.gridLayout1.setColumns(n);
Button[][] buttonMatrix=new Button[n][n];
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
buttonMatrix[j]=new Button(".");
buttonMatrix[j].setBackground(new Color(124324));
panelMatrix.add(buttonMatrix[j]);
panelMatrix.validate();
panelMatrix.repaint();
}
}
}
where I set n=4, but it could be set to any value.
But, the applet I'm writing doesn't works like I'd like to: when I
click on button1 it doesn't
happens anything, I don't see the buttons in panelMatrix (although
there is no exception
thrown).
Anyone can help?
Thanks,
Pierre Blanc
------------------------------------------------------------
http://www.teutoburgo.tk
Teutoburgo - A forest to navigate
http://www.site-map.tk
Site Map Generator
I have an AWT problem. I'd like to add some Buttons to a Panel (with a
GridLayout of
dynamic dimension). Practically when I click on button1 it should
happens this:
void button1_actionPerformed(ActionEvent e) {
int n=4;
this.gridLayout1.setRows(n);
this.gridLayout1.setColumns(n);
Button[][] buttonMatrix=new Button[n][n];
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
buttonMatrix[j]=new Button(".");
buttonMatrix[j].setBackground(new Color(124324));
panelMatrix.add(buttonMatrix[j]);
panelMatrix.validate();
panelMatrix.repaint();
}
}
}
where I set n=4, but it could be set to any value.
But, the applet I'm writing doesn't works like I'd like to: when I
click on button1 it doesn't
happens anything, I don't see the buttons in panelMatrix (although
there is no exception
thrown).
Anyone can help?
Thanks,
Pierre Blanc
------------------------------------------------------------
http://www.teutoburgo.tk
Teutoburgo - A forest to navigate
http://www.site-map.tk
Site Map Generator