View Javadoc
1   package org.woehlke.computer.kurzweil.tabs.cca.view;
2   
3   import org.woehlke.computer.kurzweil.tabs.cca.config.ObjectRegistry;
4   
5   import javax.swing.*;
6   import java.awt.*;
7   import java.awt.event.ActionEvent;
8   import java.awt.event.ActionListener;
9   
10  
11  /**
12   * TODO write doc.
13   */
14  public class PanelButtons extends JPanel implements ActionListener {
15  
16      private static final long serialVersionUID = 7526471155622776147L;
17  
18      private final JButton buttonVonNeumann;
19      private final JButton buttonMoore;
20      private final JButton buttonWoehlke;
21      private ObjectRegistry ctx;
22  
23      public PanelButtons(ObjectRegistry ctx) {
24          this.ctx = ctx;
25          JLabel neighborhood = new JLabel("Neighborhood");
26          this.buttonVonNeumann = new JButton("Von Neumann");
27          this.buttonMoore = new JButton("Moore");
28          this.buttonWoehlke = new JButton("Woehlke");
29          FlowLayout layout = new FlowLayout();
30          this.setLayout(layout);
31          this.add(neighborhood);
32          this.add(this.buttonVonNeumann);
33          this.add(this.buttonMoore);
34          this.add(this.buttonWoehlke);
35          this.buttonVonNeumann.addActionListener(this);
36          this.buttonMoore.addActionListener(this);
37          this.buttonWoehlke.addActionListener(this);
38    }
39  
40      /**
41      * TODO write doc.
42      */
43      @Override
44      public void actionPerformed(ActionEvent ae) {
45          if (ae.getSource() == this.buttonVonNeumann) {
46              this.ctx.getController().pushButtonVonNeumann();
47          } else if (ae.getSource() == this.buttonMoore) {
48              this.ctx.getController().pushButtonMoore();
49          } else if (ae.getSource() == this.buttonWoehlke) {
50              this.ctx.getController().pushButtonWoehlke();
51          }
52      }
53  }