アットウィキロゴ

x1

import java.awt.*;
import java.awt.event.*;

class pro extends Frame {
public static void main(String[] args) {
pro frame =new pro("peo");
}

public pro(String str) {
super(str);
setSize(500, 500);
setLayout(new FlowLayout());
Button bu1 = new Button("z");
bu1.addActionListener(new beck());
add(bu1);
bu1.setActionCommand("c1");

Button bu2 = new Button("x");
bu2.addActionListener(new beck());
add(bu2);
bu2.setActionCommand("c2");
setVisible(true);
addWindowListener(new stopwin());
}

class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}

class beck implements ActionListener {
public void actionPerformed(ActionEvent e) {
if ("c1".equals(e.getActionCommand()))System.out.println("as");
if ("c2".equals(e.getActionCommand()))System.out.println("mi");
}
}

}
最終更新:2010年09月28日 21:51