KnopAanKnopUit

 
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
 
public class KnoppenFrame extends JFrame {
 
  private static final long serialVersionUID = 1L;
  private JPanel jContentPane = null;
  private JButton knopLinks = null;
  private JButton knopRechts = null;
 
  /**
   * This method initializes knopLinks	
   * 	
   * @return javax.swing.JButton	
   */
  private JButton getKnopLinks() {
    if (knopLinks == null) {
      knopLinks = new JButton();
      knopLinks.setBounds(new Rectangle(29, 30, 108, 124));
      knopLinks.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
          System.out.println("actionPerformed()"); 
          knopRechts.setVisible(true);
          knopLinks.setVisible(false);
          // TODO Auto-generated Event stub actionPerformed()
        }
      });
    }
    return knopLinks;
  }
 
  /**
   * This method initializes knopRechts	
   * 	
   * @return javax.swing.JButton	
   */
  private JButton getKnopRechts() {
    if (knopRechts == null) {
      knopRechts = new JButton();
      knopRechts.setBounds(new Rectangle(166, 30, 105, 124));
      knopRechts.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
          System.out.println("actionPerformed()"); 
          knopLinks.setVisible(true);
          knopRechts.setVisible(false);
        }
      });
    }
    return knopRechts;
  }
 
  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
 
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        KnoppenFrame thisClass = new KnoppenFrame();
        thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        thisClass.setVisible(true);
      }
    });
  }
 
  /**
   * This is the default constructor
   */
  public KnoppenFrame() {
    super();
    initialize();
    this.knopRechts.setVisible(false);
  }
 
  /**
   * This method initializes this
   * 
   * @return void
   */
  private void initialize() {
    this.setSize(300, 200);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setContentPane(getJContentPane());
    this.setTitle("KnoppenAanUit");
  }
 
  /**
   * This method initializes jContentPane
   * 
   * @return javax.swing.JPanel
   */
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      jContentPane = new JPanel();
      jContentPane.setLayout(null);
      jContentPane.add(getKnopLinks(), null);
      jContentPane.add(getKnopRechts(), null);
    }
    return jContentPane;
  }
 
}

Leave a Reply