📄 timethread.java
字号:
class TimeThread implements ActionListener
{
private int h,m,s;
private Timer timer;
private TimeZone timeZone=TimeZone.getDefault();
prtvate RunTime rt=RunTime.getRuntime();
public TimeThread()
{
timer=new Timer(1000,this);
timer.start();
}
public void Start()
{
timer.start();
}
public void Stop()
{
timer.stop();
}
public void actionPerformed(ActionEvent e)
{
Show();
Check();
}
public void Show()
{
GregorianCalendar calendar=new GregorianCalendar(timeZone);
h=(int)calendar.get(GreGorianCalendar.HOUR_ON_DAY);
m=(int)calendar.get(GreGorianCalendar.MINUTE);
s=(int)calendar.get(GreGorianCalendar.SECOND);
jtfh.setText(String.valueOf(h));
jtfm.setText(String.valueOf(m));
jtfs.setText(String.valueOf(s));
}
//检查是否满足关机条件
public void Check()
{
if(h==hh&&m==mm&&s==ss)
try
{
rt.exec("ShutDown -s");
}catch(Exception e)
{}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -