//StartStopClock.java

import java.awt.*;
import java.awt.event.*;
//import java.applet.*;
import java.lang.*;

public class StartStopClock extends Panel {   
	//private static final Color bgcolor = new Color(216,216,191);
	//private static final Color bgcolor = new Color(236,236,221);
        private static final Color bgcolor = new Color(180,180,180); // beige
	
	//public ImageButton button1, button2;
	public Button button1, button2;
        public boolean IsStop;
        
        public ClockCanvas clockcanvas;
	
	public StartStopClock(){
		super();
		setLayout(null);
                setBackground(bgcolor);
		
                button1 = new Button("START");
                button2 = new Button("STOP");
                button1.setBounds(9,10,44,18);
		button2.setBounds(64,10,44,18);
		
		button1.setBackground(Color.white);
                button2.setBackground(Color.white);
                button1.setBackground(new Color(255,255,230));
                button2.setBackground(new Color(255,255,230));
                
                button1.setForeground(Color.green.darker());
                button2.setForeground(Color.red.darker());
                button1.setFont(new Font("SanSerif",Font.PLAIN,10)); 
                button2.setFont(new Font("SanSerif",Font.PLAIN,10)); 
                
                clockcanvas = new ClockCanvas();
		clockcanvas.setBounds(115,3,30,30);
		add(button1);
		add(button2);
		add(clockcanvas);
                
                IsStop = true;
                
                button1.setEnabled(true);
                button2.setEnabled(false);
                
	}
	
	public void paint(Graphics g){
		//g.draw3DRect(0,0,size().width-1,size().height-1,false);
            g.setColor(Color.white);
            g.fillRect(0,0,getSize().width,getSize().height);
            g.setColor(Color.black);
            g.drawRect(0,0,getSize().width-1,getSize().height-1);

            // Start - Stop button
            //-------------------------START BUTTON
            
            if(IsStop){
                    //g.setColor(Color.black);
                    //MaestroG.fillCircle(35,30,38,g);
                    //g.setColor(new Color(0,200,0));
                    //MaestroG.fillCircle(33,28,38,g);
                    //g.setColor(Color.green.darker());
                    //MaestroG.drawCircle(33,28,38,g);
                button1.setEnabled(true);
                button2.setEnabled(false);
                // rectangles behind actual buttons
                g.setColor(Color.green);
                g.fillRect(5,6,50,24);
                g.setColor(Color.black);
                g.drawRect(5,6,50,24);
            }
            else{
                //g.setColor(Color.gray);
                //MaestroG.fillCircle(35,30,38,g);
                //g.setColor(Color.lightGray);
                //MaestroG.fillCircle(33,28,38,g);
                //g.setColor(Color.gray);
                //MaestroG.drawCircle(33,28,38,g);
                button1.setEnabled(false);
                button2.setEnabled(true);
                // rectangles behind actual buttons
                g.setColor(Color.gray);
                g.fillRect(5,6,50,24);
                g.setColor(Color.black);
                g.drawRect(5,6,50,24);
            }
            
            //--------------------------STOP BUTTON
            
            if(!IsStop){
                //g.setColor(Color.black);
                //MaestroG.fillCircle(99,30,38,g);
                //g.setColor(Color.red);
                //MaestroG.fillCircle(97,28,38,g);
                //g.setColor(Color.red.darker());
                //MaestroG.drawCircle(97,28,38,g);
                // rectangles behind actual buttons
                g.setColor(Color.red);
                g.fillRect(60,6,50,24);
                g.setColor(Color.black);
                g.drawRect(60,6,50,24);
            }
            else{
                //g.setColor(Color.gray);
                //MaestroG.fillCircle(99,30,38,g);
                //g.setColor(Color.lightGray);
                //MaestroG.fillCircle(97,28,38,g);
                //g.setColor(Color.gray);
                //MaestroG.drawCircle(97,28,38,g);
                // rectangles behind actual buttons
                g.setColor(Color.gray);
                g.fillRect(60,6,50,24);
                g.setColor(Color.black);
                g.drawRect(60,6,50,24);
            }

	}
	
	public void pause(boolean arg){
		//clockcanvas.pause(arg);
	}
	
	public void start(){
		clockcanvas.start();
	}
	
	public void increment(){
		clockcanvas.increment();
	}
	
	public synchronized void setStatus(int CL_START, int CL_FINISH, int CL_DELTA){
		clockcanvas.setStatus(CL_START,CL_FINISH,CL_DELTA);
	}
	public synchronized void setSleepTime(int SleepTime){
		clockcanvas.setSleepTime(SleepTime);
	}
	public synchronized void reset(){
		clockcanvas.reset();
	}
	
}//End of StartStopClock.java


