import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.Timer; @SuppressWarnings("serial") public class ClockTester extends JPanel implements ActionListener { private Font titleFont, regularFont; private Timer timer; private Clock clock; public ClockTester() { clock = new Clock(); titleFont = new Font("Times", Font.BOLD, 24); regularFont = new Font("Courier", Font.BOLD, 72); timer=new Timer(10, this); timer.start(); } public ClockTester(int h, int m, int s) { super(); clock = new Clock(h,m,s); } public static void main(String[] args) { ClockTester app= new ClockTester(); JFrame window = new JFrame("Clock"); window.setSize(500, 300); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().add(app); window.setVisible(true); } public void actionPerformed(ActionEvent e) { clock.tick(); repaint(); } public void paintComponent(Graphics g){ //super.paintComponent(g); g.setColor(Color.WHITE); g.fillRect(0, 0, getWidth(),getHeight()); g.setColor(Color.BLUE); g.setFont(titleFont); g.drawString("Clock version 1.0", 20, 20); //g.drawString(balloons.size()+" Balloons", WIDTH-100, 20); g.setColor(Color.BLACK); g.setFont(regularFont); g.drawString("Clock", 50, 100); g.drawString( clock.toString() , 100, 200); } }