📄 e_clock.java
字号:
package clock;
import java.awt.*;
import java.util.Calendar;
import java.util.Date;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class e_clock extends JFrame{
JLabel Label_Time;
/** Creates a new instance of e_clock */
public e_clock() {
Container container = getContentPane();
container.setLayout( new FlowLayout());
Label_Time = new JLabel();
Date dt;
dt=new Date(System.currentTimeMillis());
String str;
long hours=dt.getHours();
long minutes=dt.getMinutes();
long seconds=dt.getSeconds();
//Calendar cal;
//cal.getInstance();
//str=Integer.toString(cal.get(Calendar.HOUR));
str=Long.toString(hours)+":"+Long.toString(minutes)+":"+Long.toString(seconds);
Label_Time.setText(str);
container.add(Label_Time);
setSize(260,180);
setVisible(true);
// System.currentTimeMillis();
}
public void tick()
{Date dt;
dt=new Date(System.currentTimeMillis());
String str;
long hours=dt.getHours();
long minutes=dt.getMinutes();
long seconds=dt.getSeconds();
//Calendar cal;
//cal.getInstance();
//str=Integer.toString(cal.get(Calendar.HOUR));
str=Long.toString(hours)+":"+Long.toString(minutes)+":"+Long.toString(seconds);
Label_Time.setText(str);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -