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

public class Hello extends javax.swing.JFrame  
{
    private JPanel panel = new JPanel();
    private JLabel alabel = new JLabel("Hello World");
    private JButton abutton = new JButton("Change my message");
    
     public Hello()
     {    super ("Hello World");  // put the title on it
          setSize (760, 600);   // 760 pixels wide, 600 pixels tall
          this.getContentPane().setLayout (null); // set it to allow us to handle layout
          panel.setBounds(10,25,this.getWidth()-20,40); // set the boundaries of the panel
          panel.add(alabel); // add the label to the panel
          panel.add(abutton); // add the button to the panel
          this.getContentPane().add(panel); // add the panel to the window
          this.abutton.addActionListener (new buttonhandler()); // add the button click
                // handler to the button
          setVisible (true);    // make it visible to the user
     }    //======================


     public static void main (String[ ] args)
     {    
         new Hello();
     }    //======================

   private class buttonhandler implements ActionListener
     {      // this runs when the "Change My Message" button is clicked
          public void actionPerformed (ActionEvent ev)      
          {    // if the text of the label is hello world, set it to goodbye, otherwise
               // make it hello
               alabel.setText((alabel.getText().equals("Hello World"))?"Goodbye World":
                "Hello World");
          }
     }    //======================
}