import javax.swing.*;
import java.awt.event.*;


/*
 * 时间显示类
 */

@SuppressWarnings("serial")
public class MyTimer extends JPanel
{
       protected int usedTime = 0;//定义初始时间为0
        public Timer timer;
        public JLabel usedTimeLabel = new JLabel("用时:");
        public JTextField timeText = new JTextField(5);
        protected  MyTimer()
        {
                timeText.setEditable(false);
                timeText.setText("0分0秒");
                setVisible(true);
                timer = new Timer(1000,new TimerListener());
        }
        class TimerListener implements ActionListener//时间显示监听
        {           
                public void actionPerformed(ActionEvent e)
                {
                        usedTime++;
                        timeText.setText(usedTime/60+"分"+usedTime%60+"秒"); //显示所用时间,分秒                       
                }
        }

}
最近下载更多
xingxing1234  LV10 2023年3月22日
floweyws  LV6 2022年6月3日
leslie123456  LV4 2018年7月9日
lw19900921  LV25 2018年7月5日
wyx065747  LV67 2017年12月10日
半路出家  LV2 2014年11月13日
hello  LV7 2014年6月17日
骑着猪猪去逛街  LV32 2014年1月7日
最代码官方  LV167 2012年10月31日
yihui1229  LV13 2012年10月31日
最近浏览更多
xingxing1234  LV10 2023年3月22日
微信网友_6191697646571520  LV6 2022年11月24日
SZEPEZS  LV8 2022年6月10日
floweyws  LV6 2022年6月3日
liuqiang1314520 2020年10月16日
暂无贡献等级
675104182  LV14 2020年9月22日
hxb2000  LV1 2020年6月5日
a1677596408  LV23 2020年5月16日
lllpppwww  LV5 2020年4月1日
SIMONZSK  LV3 2019年12月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友