countdowntester.java
来自「java语言与面向对象程序设计源程序」· Java 代码 · 共 34 行
JAVA
34 行
import java.awt.*;
import java.awt.event.*;
public class CountDownTester extends Frame implements ActionListener
{ private Button start = new Button("Start");
private Button show = new Button("Show");
private TextField display = new TextField(25);
private CountDown count = new CountDown(show,25);
private class WindowCloser extends WindowAdapter
{ public void windowClosing(WindowEvent we)
{ System.exit(0); }
}
public CountDownTester()
{ super("CountDown Tester");
setLayout(new FlowLayout());
add(start);
add(show);
add(display);
show.addActionListener(this);
start.addActionListener(this);
count.addActionListener(this);
addWindowListener(new WindowCloser());
pack(); show();
}
public void actionPerformed(ActionEvent e)
{ if (e.getSource() == start)
count.startCounting();
else if (e.getSource() == show)
display.setText("Event came from: " + e.getActionCommand());
}
public static void main(String args[])
{ CountDownTester c = new CountDownTester(); }
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?