java 简易时钟
来源:百度知道 编辑:UC知道 时间:2024/05/26 07:57:42
由于本人只学了 awt 和 applet ,所以最好用这两个~~
谢谢了~
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
final public class LocalTimePanel extends JFrame {
private JComboBox timeBox;
private JTextField timeField;
private SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy年M月d日 a h时m分s秒");
public LocalTimePanel(String title) throws HeadlessException {
super(title); init(); doLay(); handleEvents();
}
private void init() {
timeBox = new JComboBox(TimeZone.getAvailableIDs());
timeField = new JTextField(20);
}
private void doLay() {
Container container = getContentPane();
container.add(timeBox, BorderLayout.NORTH);
container.add(timeField, BorderLayout.SOUTH);
pack();
setVisible(true);
}
private void handleEvents() {
timeBox.addItemListener(new TimeSelectedChangedListener());
setDefaultCloseOperat