import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Aj34 extends Applet implements ActionListener
{
Button []buts;
String names[]={"A","B","C","D","E","F","G","H","I","j","k","l"};
boolean toggle=true;
public void init()
{
setLayout(new GridLayout(3,4,5,5));
buts=new Button[names.length];
for(int i=0;i<names.length;i++)
{
buts=new Button("按钮"+names);
buts.addActionListener(this);
add(buts);
}
}
public void actionPerformed(ActionEvent e)
{
if(toggle)
setLayout(new GridLayout(4,3,5,8));
else
setLayout(new GridLayout(3,4,8,5));
toggle=! toggle;
validate();
}
}
为什么按键后就会“三行四列”“四行三列”不同转化?(主要是public void actionPerformed(ActionEvent e)没看懂)
|