1.java连连看里设置150秒倒计时,连连连重行开始游戏时时间再次从150秒开始倒计时的码连代码怎么写,急!代码美女资讯源码!连连连!码连php qrcode 源码!代码编写商城源码!连连连!码连!代码
java连连看里设置150秒倒计时,连连连重行开始游戏时时间再次从150秒开始倒计时的码连代码怎么写,急!代码!连连连ffmpeg 源码阅读!码连!代码空包100源码!!!
参考一下吧。import java.awt.FlowLayout;import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Program {
static int seconds = ;
private TimeThread tt = null;
private boolean ttFlag = false;
private void init() {
final JLabel tip = new JLabel();
final JButton start = new JButton("开始");
final JButton end = new JButton("结束");
JFrame f = new JFrame();
f.setLayout(new FlowLayout(5));
f.add(tip);
f.add(start);
f.add(end);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
f.setSize(, );
f.setLocationRelativeTo(null);
start.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
start.setEnabled(false);
tip.setFont(new Font("宋体",Font.BOLD,));
ttFlag = true;
tt = new TimeThread(tip);
tt.start();
}
});
end.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
start.setEnabled(true);
tip.setText("");
Program.seconds = ;
ttFlag = false;
}
});
}
/
*** @param args
*/
public static void main(String[] args) {
new Program().init();
}
class TimeThread extends Thread {
private JLabel tip;
TimeThread(JLabel tip) {
this.tip = tip;
}
@Override
public void run() {
int seconds = Program.seconds;
tip.setText(seconds+"");
while (seconds-- > 0 && ttFlag) {
tip.setText(seconds+"");
try {
Thread.sleep();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
}
2024-11-15 06:46
2024-11-15 06:35
2024-11-15 06:17
2024-11-15 05:43
2024-11-15 05:03
2024-11-15 05:00
2024-11-15 04:26
2024-11-15 04:12