主题:help me !!!!!!!!!!!!!!!!!!!!!!!
交谈中请勿轻信汇款、中奖消息,勿轻易拨打陌生电话。
hmily(342925341) 23:20:46
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]
hmily(342925341) 23:20:46
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]