import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ClickMe { // Add any class or instance variables here. public static void initialize () { // Add any initialization code here. // This code will be called only once at the start of the program. } public static void buttonAction () { // Add code to handle a button click here. // This code will be called every time the user clicks the button. // Call the "windowPrint" function to display text to the window. windowPrint ("click"); } // You should not need to change any code below this point. public static JLabel label = new JLabel (); public static void windowPrint (String s) { label.setText (s); } public static void main (String[] args) { initialize (); JButton button = new JButton ("Click Me!"); button.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent e) { buttonAction(); } }); label.setText ("-----------------------------------------"); JPanel panel = new JPanel (); panel.add (Box.createRigidArea (new Dimension (20,10))); panel.add (button); panel.add (Box.createRigidArea (new Dimension (20,10))); panel.add (label); panel.add (Box.createRigidArea (new Dimension (20,10))); JFrame frame = new JFrame ("Program"); frame.getContentPane().add (panel, BorderLayout.WEST); frame.addWindowListener(new WindowAdapter() { public void windowClosing (WindowEvent e) { System.exit(0); } }); frame.pack (); frame.setVisible(true); } }