title: How do I implement a "if/then" statement with buttons in Java?
body: <p>So, if you can't already tell by my title, I'm really new to java. I'm trying to write an applet that when you click on a button (button x for instance) a new text window will appear with some information on it. I'm just wondering how I would implement that into my code. Thank you for any help you can give me. </p>
  
  <pre><code>import java.awt.Container;
  import java.awt.FlowLayout;
  
  import javax.swing.JApplet;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  
  public class Button1 extends JApplet {
  
  private JButton b1 = new JButton("Button 1"), b2 = new JButton("Button 2"), b3 = new JButton("Button 3");
  
    public void init() {
      Container cp = getContentPane();
      cp.setLayout(new FlowLayout());
      cp.add(b1);
      cp.add(b2);
      cp.add(b3);
  
  
    }
  
  
    public static void main(String[] args) {
      run(new Button1(), 200, 50);
    }
  
    public static void run(JApplet applet, int width, int height) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().add(applet);
      frame.setSize(width, height);
      applet.init();
      applet.start();
      frame.setVisible(true);
    }
  } ///:~
  </code></pre>