import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class GUIWButton {

    public GUIWButton() {

	JFrame frame = new JFrame("First GUI");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	JPanel panel = new JPanel();

	panel.setBackground(Color.red);
	panel.setPreferredSize(new Dimension(250, 75));
	
	JLabel label = new JLabel("Count is 0");

	JButton button = new JButton("Push Me!");
	button.addActionListener(new ButtonListener(label));
	
	panel.add(label);
	panel.add(button);
	frame.getContentPane().add(panel);
	frame.pack(); //size to the preferred size
	frame.setVisible(true); 

    }

    private class ButtonListener implements ActionListener {

	JLabel label;
	int count;

	public ButtonListener(JLabel label) {
	    this.label = label;
	    this.count = 0;
	}

	public void actionPerformed(ActionEvent event) {
	    count++;
	    label.setText("Count is " + count);
	}

    }


    public static void main(String[] args) {
	GUIWButton mygui = new GUIWButton();
	System.out.println("running...");
    }
	

}