import javax.swing.*;  // for JFrame and stuff
import java.awt.*;  // for colors
import java.awt.event.*;  // for ActionListener

public class Controller extends JFrame implements ActionListener
{
public JButton incButton;
public int counter = 0;
public Font myFont;
public Timer myTimer;

public Controller()
   {
   setSize( 500, 200 );
	setLocation( 20, 20 );
	setDefaultCloseOperation( EXIT_ON_CLOSE );
	setVisible( true );

	JFrame newFrame = new JFrame();
   newFrame.setSize( 100, 100 );
	newFrame.setLocation( 200, 300 );
	newFrame.setLayout( new FlowLayout() );
	
	incButton = new JButton("increment");
	newFrame.add(incButton);
	incButton.addActionListener( this );
	newFrame.setVisible( true );
	
	myFont = new Font ("Arial", Font.PLAIN, 62 );	
	
	myTimer = new Timer( 1000, this );		
	myTimer.start();
   }  // end constructor

public void paint( Graphics g )
   {
	g.setColor( Color.lightGray );
	g.fillRect( 0, 0,  500, 200 );
	g.setFont( myFont );
   g.setColor( Color.red );
   g.drawString( Integer.toString(counter), 60, 100);
	}

public static void main( String args [])
   {
   Controller  app = new Controller();
   }  // end main

public void actionPerformed( ActionEvent e )
   {
	if ((e.getSource() == incButton) || (e.getSource() == myTimer))
	   {
		counter = counter + 1;
		repaint();
		}
   }
}  // end class 

