Browse Source

Clicking the LED-Buttons now actually changes the xolor of the button.

Max Nuding 12 years ago
parent
commit
e9465e7579
1 changed files with 13 additions and 6 deletions
  1. 13
    6
      Cube Control/layerEditFrame.java

+ 13
- 6
Cube Control/layerEditFrame.java View File

@@ -16,7 +16,7 @@ public class layerEditFrame extends JFrame {
16 16
   private JPanel panelLED1 = new JPanel(null, true);
17 17
   JButton[][] ledPanels = new JButton[8][8];
18 18
   static ImageIcon on = new ImageIcon("LEDon.png");
19
-  static ImageIcon off = new ImageIcon("LEDff.png");
19
+  static ImageIcon off = new ImageIcon("LEDoff.png");
20 20
 
21 21
   // Ende Attribute
22 22
 
@@ -37,8 +37,15 @@ public class layerEditFrame extends JFrame {
37 37
 
38 38
     for(int i = 0; i < 8; i++){
39 39
       for(int j = 0; j < 8; j++){
40
+         final int finalI = i;
41
+         final int finalJ = j;
40 42
          ledPanels[i][j] = new JButton(on);
41 43
          ledPanels[i][j].setBounds((i*20)+5, (j*20)+5, 15, 15);
44
+         ledPanels[i][j].addActionListener(new ActionListener() {
45
+           public void actionPerformed(ActionEvent evt) {
46
+             btnClicked(finalI, finalJ);
47
+           }
48
+         });
42 49
          ledPanels[i][j].setVisible(true);
43 50
          cp.add(ledPanels[i][j]);
44 51
       }
@@ -80,13 +87,13 @@ public class layerEditFrame extends JFrame {
80 87
     // Anfang Komponenten
81 88
 
82 89
     // Ende Komponenten
83
-  /*public void btnClicked(){
84
-    if (getIcon() == on){
85
-      setIcon(off);
90
+  public void btnClicked(int i, int j){
91
+    if (ledPanels[i][j].getIcon() == on){
92
+      ledPanels[i][j].setIcon(off);
86 93
     } else {
87
-      setIcon(on);
94
+      ledPanels[i][j].setIcon(on);
88 95
     }
89
-  } */
96
+  }
90 97
 
91 98
   public void cancel(){
92 99
     dispose();

Loading…
Cancel
Save