Java教学GUI实例
Frame f = new Frame("test");
Panel p = new Panel();
f.add(p);
Button b1 = new Button("按钮");
p.add(b1);
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.out.println("success");
}
});
f.setSize(300,400);
f.setVisible(true);
}
private class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
System.out.println("success");
}
}