/**
 * Class CalculatorGui - write a description of the class here
 * 
 * @author: Kleanthis Thramboulidis
 * date: 
 */

import java.awt.*;
import java.awt.event.*;


public class CalculatorGui extends Frame
{
      public Button button0, button1;
      public TextField display;
     
      public CalculatorGui()
      {
	   super("JAVA Polish Reverse Calculator");

      this.setFont(new Font("TimesRoman", Font.PLAIN, 12));
      this.setBackground(Color.blue);
      
		this.setSize(new Dimension(283,297));
      this.setLocation(50,100);      

      this.setVisible(true);
      this.toFront();            
      this.setResizable(false);  
      this.addWindowListener(new CloseWindowAndExit());
      
      button0=new Button("0");
 		this.add(button0);
		button0.setBounds(new Rectangle(64, 265, 35, 28));
		button0.setFont(new Font("TimesRoman",Font.PLAIN,14));
		button0.setBackground(Color.cyan);
		button0.setForeground(Color.blue);		
		button0.addActionListener(new Button0Handler(this));
		
		button1=new Button("1");
 		this.add(button1);
		button1.setBounds(new Rectangle(64, 232, 35, 28));
		button1.setFont(new Font("TimesRoman",Font.PLAIN,14));
		button1.setBackground(Color.cyan);
		button1.setForeground(Color.blue);		
		button1.addActionListener(new Button0Handler(this));
				
		display = new TextField("0",14);
      this.add(display);
      display.setEditable(false);  
		display.setBounds(new Rectangle(13, 55, 257, 30));
		}  
}		



class CloseWindowAndExit extends WindowAdapter
  {
    public void windowClosing (WindowEvent closeWindowAndExit)
     {
      System.exit(0);
     }
  } 


class Button0Handler implements ActionListener {
		public CalculatorGui calcGui;
		int count;
		
		public Button0Handler(CalculatorGui calcGui) {
			this.calcGui = calcGui;
			count = 0;
		}
		
     	public void actionPerformed(ActionEvent pushingButton0){ 
			//	System.out.println("button0 was pressed");
			calcGui.display.setText("button0 was pressed " + count +" times");
			count++;
       	}
   }