Jump to content

Updating Digital Clock Java

- - - - -

  • Please log in to reply
No replies to this topic

#1
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
Done something however didn't present it.
Hope you guys enjoy !

import java.awt.*;

import javax.swing.*;

import javax.swing.Timer;

import java.awt.event.*;

import java.util.*;

import java.text.*;

class DigiClock extends JLabel implements ActionListener {

	private DateFormat df = DateFormat.getTimeInstance();

	

	public DigiClock() {

		setHorizontalAlignment(JLabel.CENTER);

		setOpaque(true);

		setBackground(Color.white);

		setFont(new Font("Verdana", Font.BOLD,26));

		Timer tim = new Timer(1000,this);

		tim.start();

	}

	public DigiClock(String zone) {

		this();

		df.setTimeZone(TimeZone.getTimeZone(zone));

	}

	public void actionPerformed(ActionEvent e) {

		setText(df.format(new Date()));

	}

}

public class DemoDigiClock extends JFrame {

		private DigiClock DC = new DigiClock();

		public DemoDigiClock() {

			JLabel l1 = new JLabel("Local time",JLabel.CENTER);

			l1.setFont(new Font("Serif",Font.PLAIN,18));

			setLayout(new GridLayout(2,2,5,5));

			add(DC); add(l1);

			setSize(250,125);

			setVisible(true);

	}

		public static void main(String[] arg) {

			new DemoDigiClock();

		}

}
For those who doesn't understand this, I recommend you read more about java...
Posted Image




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users