主题:help me !!!
import java.awt.*;
import java.awt.event.*;
public class awt extends Frame{
private final String names[]={"one","two","three","four","five","six"};
private Button[] buttons=new Button[6];
private boolean flag=true;
final GridLayout layout1=new GridLayout(2,3,5,10);
final GridLayout layout2=new GridLayout(3,2);
public awt(String title) {
super(title);
setLayout();
ActionListener listener=new ActionListener(){
setLayout(); //这里错啦 why?
awt.this.validate(); //这里错啦 why?
};
for(int i=0;i<buttons.length;i++){
buttons[i]=new Button(names[i]);
buttons[i].addActionlistener(listener);
add(buttons[i]);
}
setSize(250,250);
setVisible(true);
}
private void setLayout(){
if(flag)
setLayout(layout1);
else
setLayout(layout2);
flag=!flag;
}
public static void main(String[] args) {
new awt("java");
}
}[em10][em10][em10]ffff
import java.awt.event.*;
public class awt extends Frame{
private final String names[]={"one","two","three","four","five","six"};
private Button[] buttons=new Button[6];
private boolean flag=true;
final GridLayout layout1=new GridLayout(2,3,5,10);
final GridLayout layout2=new GridLayout(3,2);
public awt(String title) {
super(title);
setLayout();
ActionListener listener=new ActionListener(){
setLayout(); //这里错啦 why?
awt.this.validate(); //这里错啦 why?
};
for(int i=0;i<buttons.length;i++){
buttons[i]=new Button(names[i]);
buttons[i].addActionlistener(listener);
add(buttons[i]);
}
setSize(250,250);
setVisible(true);
}
private void setLayout(){
if(flag)
setLayout(layout1);
else
setLayout(layout2);
flag=!flag;
}
public static void main(String[] args) {
new awt("java");
}
}[em10][em10][em10]ffff