Rabu, 21 Desember 2011

sopWatch

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class StopWatchFrame extends javax.swing.JFrame
        implements Runnable{
   
    /** Creates new form NewJFrame */
    public StopWatchFrame() {
        super("Stop Watch");
        initComponents();
    }
   
   
    private void initComponents() {
        numberLabel = new javax.swing.JLabel();
        numberText = new javax.swing.JTextField();
        startButton = new javax.swing.JButton();
        stopButton = new javax.swing.JButton();
       
        this.setLayout(new java.awt.GridLayout(0, 2));
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
       
        numberLabel.setText("timer");
        this.add(numberLabel);
       
        numberText.setText("0");
        this.add(numberText);
       
        startButton.setText("Start");
        this.add(startButton);
       
       
        stopButton.setText("Stop");
        this.add(stopButton);
       
    }
   
    public void startButtonAction(){

    }
   
    public void stopButtonAction(){

    }
    public static void main(String args[]) {
        StopWatchFrame test = new StopWatchFrame();
        test.setSize(300,100);
        test.setVisible(true);
    }
   
   
    // Variables declaration - do not modify
    private javax.swing.JLabel numberLabel;
    private javax.swing.JTextField numberText;
    private javax.swing.JButton startButton;
    private javax.swing.JButton stopButton;
    private Thread thread;
    private int time;
    private boolean start=false;
    // End of variables declaration
   
    public boolean isStart() {
        return start;
    }
   
    public void setStart(boolean start) {
        this.start = start;
    }
   
    public int getTime() {
        return time;
    }
   
    public void setTime(int time) {
        this.time = time;
    }
   
    public void run() {
        try {
            while(isStart()){
                Thread.sleep(100);

            }
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
    }
   
}

Tidak ada komentar:

Posting Komentar