| 18 | * D:�ô�����ʾ |
| 19 | */ |
| 20 | public class ButtonDemo { |
| 21 | public static void main(String[] args) { |
| 22 | // ����������� |
| 23 | Frame f = new Frame(); |
| 24 | // �������� |
| 25 | f.setTitle("��ť�¼�"); |
| 26 | f.setBounds(500, 250, 400, 300); |
| 27 | // ���� |
| 28 | f.setLayout(new FlowLayout()); |
| 29 | |
| 30 | // ������ť���� |
| 31 | Button bu = new Button("���Ұ�"); |
| 32 | // bu.setSize(20, 10); |
| 33 | |
| 34 | // �Ѱ�ť���ӵ����� |
| 35 | f.add(bu); |
| 36 | |
| 37 | // ע���¼� |
| 38 | |
| 39 | // ע�ᰴť����¼� |
| 40 | bu.addActionListener(new ActionListener() { |
| 41 | @Override |
| 42 | public void actionPerformed(ActionEvent e) { |
| 43 | System.out.println("���ٵ�����"); |
| 44 | } |
| 45 | }); |
| 46 | |
| 47 | // ����ر��¼� |
| 48 | f.addWindowListener(new WindowAdapter() { |
| 49 | @Override |
| 50 | public void windowClosing(WindowEvent e) { |
| 51 | System.exit(0); |
| 52 | } |
| 53 | }); |
| 54 | |
| 55 | // ���ô�����ʾ |
| 56 | f.setVisible(true); |
| 57 | } |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected