Java Code

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class ClockTimer extends JApplet implements ActionListener
{
	JLabel clock;
	javax.swing.Timer timer;
	public void init( )
	{
		setLayout( new FlowLayout( ) );
		clock = new JLabel( "Timer" );
		timer = new javax.swing.Timer( 1000, this );
		timer.start( );
		add( clock );
	}
    public void actionPerformed(ActionEvent e) 
    {
        //... Get the current time.
        Calendar now = Calendar.getInstance();
        int h = now.get(Calendar.HOUR_OF_DAY);
        int m = now.get(Calendar.MINUTE);
        int s = now.get(Calendar.SECOND);
        clock.setText( "Time now: " + h + ":" + m + ":" + s );
    }
}

©2007 by E.S.Boese. All Rights Reserved