stopwatch.java
来自「著名IT公司ILog的APS高级排产优化引擎」· Java 代码 · 共 54 行
JAVA
54 行
package com.power.pipeengine;/** * <p>Title: PIPE Engine</p> * <p>Description: Global Planning Optimization Engine</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Paraster, Inc.</p> * @author unascribed * @version 1.0 */import java.util.*;import com.power.util.Message.*;import java.text.*;import javax.swing.*;import com.power.pipeengine.EngineUI.*;import java.awt.*;public class StopWatch extends TimerTask { public StopWatch( JLabel aLabel ) { myLabel = aLabel; myLabel.setText( sdfInput.format( new Date( 0 ) ) ); myLabel.setForeground( Color.blue ); } private Date startDate = new Date(); public long elapsedTime = 0; private long startTime = startDate.getTime(); private SimpleDateFormat sdfInput = new SimpleDateFormat( "mm:ss:SSS" ); private JLabel myLabel;// = new JLabel(); public void run() { elapsedTime = new Date().getTime() - startTime; myLabel.setText( sdfInput.format( new Date( elapsedTime) ) ); //myDisplay.repaint( myDisplay.getX(), myDisplay.getY(), // myDisplay.getWidth(), myDisplay.getHeight() ); /*try { //SwingUtilities.invokeLater( runnable ); SwingUtilities.invokeLater( UIEventUpdateThread.getInstance() ); } catch (Exception e ) {}*/ } public JLabel getLabel() { return myLabel; } public void reset() { elapsedTime = 0; myLabel.setText( sdfInput.format( new Date( 0 ) ) ); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?