// this is the basics of gui stuff import java.awt.*; import javax.swing.*; import java.awt.event .*; public class J04Swing implements ActionListener { // note the concept of class data private static JLabel myLabel; public static void main(String[] args) { myLabel = new JLabel("Some Text"); JButton myButton = new JButton("Press Me"); myButton.addActionListener(new J04Swing()); JFrame jf = new JFrame(); jf.getContentPane().setLayout(new FlowLayout()); jf.getContentPane().add(myLabel); jf.getContentPane().add(myButton); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); } public void actionPerformed(ActionEvent e) { myLabel.setText("Alternate Text"); } }