JAvaの表示時間のプログラム

529 ワード

ダイアログボックスに現在の時間を表示できるサンプル・ウィジェット
import java.util.Date;

import javax.swing.JDialog;
import javax.swing.JLabel;

public class ClockView extends JDialog {

	JLabel label = new JLabel();

	public ClockView() {
		this.add(label);
		this.setSize(200, 200);
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

		this.setVisible(true);
	}

	public static void main(String[] args) {
		ClockView time = new ClockView();
		while (true) {
			Date date = new Date();
			time.label.setText(date.toString());
		}
	}

}