📄 timethread.java
字号:
//package mine;
import javax.swing.*;
public class TimeThread extends Thread
{
int numOfSecond = 0;
JLabel timeLabel;
MainFrame theFrame;
public TimeThread(MainFrame theFrame)
{
this.timeLabel = theFrame.jLabelTime;
this.theFrame = theFrame;
}
public void run()
{
numOfSecond = 0;
outer:
while(true)
{
if(theFrame.isRestart)
{
try
{
Thread.sleep(1000);
numOfSecond++;
if(numOfSecond < 10)
timeLabel.setText("000"+numOfSecond);
else
if(numOfSecond < 100)
timeLabel.setText("00"+numOfSecond);
else
if(numOfSecond < 1000)
timeLabel.setText("0"+numOfSecond);
if(numOfSecond == 9999)
break;
}
catch(InterruptedException e)
{
JOptionPane.showMessageDialog(null,"InterruptedException occured here: " + e);
}
}
else
{/*
if(theFrame.sumOfNotMine==0)
{
JOptionPane.showMessageDialog(null,"You Win!!!");
break outer;
}
else
{
JOptionPane.showMessageDialog(null,"You Lose!!!");
break outer;
}*/
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -