Bläddra i källkod

Added Frame functionality

Thomas Buck 12 år sedan
förälder
incheckning
92c9fc8d32
3 ändrade filer med 1093 tillägg och 261 borttagningar
  1. 8
    7
      Cube Control/cubeWorker.java
  2. 128
    77
      Cube Control/frame.java
  3. 957
    177
      Cube Control/frame.jfm

+ 8
- 7
Cube Control/cubeWorker.java Visa fil

1
 /*
1
 /*
2
- * cube.c
2
+ * cubeWorker.java
3
  *
3
  *
4
  * Copyright 2011 Thomas Buck <xythobuz@me.com>
4
  * Copyright 2011 Thomas Buck <xythobuz@me.com>
5
  * Copyright 2011 Max Nuding <max.nuding@gmail.com>
5
  * Copyright 2011 Max Nuding <max.nuding@gmail.com>
43
     // Returns how many animations are defined
43
     // Returns how many animations are defined
44
     public int numOfAnimations() {
44
     public int numOfAnimations() {
45
 
45
 
46
-           return 0;
46
+           return 3;
47
     }
47
     }
48
     
48
     
49
-    // Selects an animation, on wich the frame specific functions operate
49
+    // Selects an animation, on which the frame specific functions operate
50
     // Returns -1 if it does not exist
50
     // Returns -1 if it does not exist
51
     public int selectAnimation(int index) {
51
     public int selectAnimation(int index) {
52
 
52
 
55
     
55
     
56
     public String getAnimationName(int index) {
56
     public String getAnimationName(int index) {
57
 
57
 
58
-           return "Test";
58
+           return "TestAnim";
59
     }
59
     }
60
     
60
     
61
     public void setAnimationName(int index, String s) {
61
     public void setAnimationName(int index, String s) {
65
     // Returns how many frames are in the current animation
65
     // Returns how many frames are in the current animation
66
     public int numOfFrames() {
66
     public int numOfFrames() {
67
 
67
 
68
-           return 0;
68
+           return 3;
69
     }
69
     }
70
     
70
     
71
     public String getFrameName(int index) {
71
     public String getFrameName(int index) {
131
     
131
     
132
     public String[] getSerialPorts() {
132
     public String[] getSerialPorts() {
133
 
133
 
134
-           return null;
134
+           String[] sPorts = {"Select serial port..."};
135
+           return sPorts;
135
     }
136
     }
136
     
137
     
137
     // Returns true if last saved state != current state
138
     // Returns true if last saved state != current state
138
     public boolean changedStateSinceSave() {
139
     public boolean changedStateSinceSave() {
139
 
140
 
140
-           return false;
141
+           return true;
141
     }
142
     }
142
 }
143
 }

+ 128
- 77
Cube Control/frame.java Visa fil

3
 import javax.swing.*;
3
 import javax.swing.*;
4
 
4
 
5
 /*
5
 /*
6
- * cube.c
6
+ * frame.java
7
  *
7
  *
8
  * Copyright 2011 Thomas Buck <xythobuz@me.com>
8
  * Copyright 2011 Thomas Buck <xythobuz@me.com>
9
  * Copyright 2011 Max Nuding <max.nuding@gmail.com>
9
  * Copyright 2011 Max Nuding <max.nuding@gmail.com>
28
 public class frame extends JFrame {
28
 public class frame extends JFrame {
29
   // Anfang Variablen
29
   // Anfang Variablen
30
   private Canvas cubeCanvas = new Canvas();
30
   private Canvas cubeCanvas = new Canvas();
31
+
32
+  // Anfang Attribute
31
   private JButton editA = new JButton();
33
   private JButton editA = new JButton();
32
   private JButton editB = new JButton();
34
   private JButton editB = new JButton();
33
   private JButton editC = new JButton();
35
   private JButton editC = new JButton();
37
   private JButton editG = new JButton();
39
   private JButton editG = new JButton();
38
   private JButton editH = new JButton();
40
   private JButton editH = new JButton();
39
   private DefaultListModel frameListModel = new DefaultListModel();
41
   private DefaultListModel frameListModel = new DefaultListModel();
40
-  private JList frameList = new JList(frameListModel);
42
+  private JList frameList = new JList();
43
+  private JScrollPane frameListScrollPane = new JScrollPane(frameList);
41
   private JButton frameUp = new JButton();
44
   private JButton frameUp = new JButton();
42
   private JButton frameDown = new JButton();
45
   private JButton frameDown = new JButton();
43
   private JButton frameAdd = new JButton();
46
   private JButton frameAdd = new JButton();
44
   private JButton frameRemove = new JButton();
47
   private JButton frameRemove = new JButton();
45
-  private DefaultListModel animationListModel = new DefaultListModel();
46
-  private JList jList2 = new JList(animationListModel);
48
+  private JList jList2 = new JList();
49
+  private DefaultListModel jList2Model = new DefaultListModel();
50
+  private JScrollPane jList2ScrollPane = new JScrollPane(jList2);
47
   private JButton animUp = new JButton();
51
   private JButton animUp = new JButton();
48
   private JButton animDown = new JButton();
52
   private JButton animDown = new JButton();
49
   private JButton animAdd = new JButton();
53
   private JButton animAdd = new JButton();
51
   private JTextField animPath = new JTextField();
55
   private JTextField animPath = new JTextField();
52
   private JButton load = new JButton();
56
   private JButton load = new JButton();
53
   private JButton save = new JButton();
57
   private JButton save = new JButton();
54
-  private String[] jComboBox1Daten = {"Select serial port..."};
55
-  private JComboBox jComboBox1 = new JComboBox(jComboBox1Daten);
58
+  private JComboBox jComboBox1 = new JComboBox();
56
   private JButton upload = new JButton();
59
   private JButton upload = new JButton();
57
   private JButton download = new JButton();
60
   private JButton download = new JButton();
58
   private JLabel jLabel4 = new JLabel();
61
   private JLabel jLabel4 = new JLabel();
59
   private JTextField frameRemaining = new JTextField();
62
   private JTextField frameRemaining = new JTextField();
60
-  
63
+  // Ende Attribute
64
+
61
   private cubeWorker worker = new cubeWorker();
65
   private cubeWorker worker = new cubeWorker();
62
   // Ende Variablen
66
   // Ende Variablen
63
 
67
 
64
   private int saveExitDialog() {
68
   private int saveExitDialog() {
65
     String[] Optionen = {"Yes", "No"};
69
     String[] Optionen = {"Yes", "No"};
66
-    int Auswahl = JOptionPane.showOptionDialog(this, "Save?", "Yes/No", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
70
+    int Auswahl = JOptionPane.showOptionDialog(this, "Do you want to save your changes?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
67
     if (Auswahl == JOptionPane.YES_OPTION) {
71
     if (Auswahl == JOptionPane.YES_OPTION) {
68
        worker.saveState(animPath.getText());
72
        worker.saveState(animPath.getText());
69
        return 1;
73
        return 1;
72
     }
76
     }
73
   }
77
   }
74
 
78
 
79
+  private void errorMessage(String s) {
80
+	String[] Optionen = {"OK"};
81
+	JOptionPane.showOptionDialog(this, s, "Error!", JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE, null, Optionen, Optionen[0]);
82
+  }
83
+
75
   public frame(String title) {
84
   public frame(String title) {
76
     // Frame-Initialisierung
85
     // Frame-Initialisierung
77
     super(title);
86
     super(title);
78
 
87
 
79
-    frameListModel.add(0, "Frame 1");
80
-    frameListModel.add(1, "Frame 2");
81
-    frameListModel.add(2, "Frame 3");
82
-    animationListModel.add(0, "Animation 1");
83
-    animationListModel.add(1, "Animation 2");
84
-    animationListModel.add(2, "Animation 3");
88
+    String[] sPorts = worker.getSerialPorts();
89
+    for(int i = 0; i < sPorts.length; i++){
90
+      jComboBox1.addItem(sPorts[i]);
91
+    }
92
+    
93
+    for(int i = 0; i < worker.numOfAnimations(); i++){
94
+      jList2Model.addElement(worker.getAnimationName(i));
95
+    }
96
+    for(int i = 0; i < worker.numOfFrames(); i++){
97
+      frameListModel.add(i, worker.getFrameName(i));
98
+    }
85
 
99
 
86
     addWindowListener(new WindowAdapter() {
100
     addWindowListener(new WindowAdapter() {
87
       public void windowClosing(WindowEvent evt) {
101
       public void windowClosing(WindowEvent evt) {
91
              System.exit(0);
105
              System.exit(0);
92
       }
106
       }
93
     });
107
     });
94
-    int frameWidth = 662;
95
-    int frameHeight = 416;
108
+    int frameWidth = 661; 
109
+    int frameHeight = 417;
96
     setSize(frameWidth, frameHeight);
110
     setSize(frameWidth, frameHeight);
97
     Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
111
     Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
98
     int x = (d.width - getSize().width) / 2;
112
     int x = (d.width - getSize().width) / 2;
107
     cp.add(cubeCanvas);
121
     cp.add(cubeCanvas);
108
     editA.setBounds(264, 8, 107, 25);
122
     editA.setBounds(264, 8, 107, 25);
109
     editA.setText("Layer A");
123
     editA.setText("Layer A");
124
+    editA.setFont(new Font("Dialog", Font.PLAIN, 13));
110
     cp.add(editA);
125
     cp.add(editA);
111
     editA.addActionListener(new ActionListener() {
126
     editA.addActionListener(new ActionListener() {
112
       public void actionPerformed(ActionEvent evt) {
127
       public void actionPerformed(ActionEvent evt) {
113
-        editAActionPerformed(evt);
128
+        editA_ActionPerformed(evt);
114
       }
129
       }
115
     });
130
     });
116
 
131
 
117
     editB.setBounds(264, 40, 107, 25);
132
     editB.setBounds(264, 40, 107, 25);
118
     editB.setText("Layer B");
133
     editB.setText("Layer B");
134
+    editB.setFont(new Font("Dialog", Font.PLAIN, 13));
119
     cp.add(editB);
135
     cp.add(editB);
120
     editB.addActionListener(new ActionListener() {
136
     editB.addActionListener(new ActionListener() {
121
       public void actionPerformed(ActionEvent evt) {
137
       public void actionPerformed(ActionEvent evt) {
122
-        editBActionPerformed(evt);
138
+        editB_ActionPerformed(evt);
123
       }
139
       }
124
     });
140
     });
125
 
141
 
126
     editC.setBounds(264, 72, 107, 25);
142
     editC.setBounds(264, 72, 107, 25);
127
     editC.setText("Layer C");
143
     editC.setText("Layer C");
144
+    editC.setFont(new Font("Dialog", Font.PLAIN, 13));
128
     cp.add(editC);
145
     cp.add(editC);
129
     editC.addActionListener(new ActionListener() {
146
     editC.addActionListener(new ActionListener() {
130
       public void actionPerformed(ActionEvent evt) {
147
       public void actionPerformed(ActionEvent evt) {
131
-        editCActionPerformed(evt);
148
+        editC_ActionPerformed(evt);
132
       }
149
       }
133
     });
150
     });
134
 
151
 
135
     editD.setBounds(264, 104, 107, 25);
152
     editD.setBounds(264, 104, 107, 25);
136
     editD.setText("Layer D");
153
     editD.setText("Layer D");
154
+    editD.setFont(new Font("Dialog", Font.PLAIN, 13));
137
     cp.add(editD);
155
     cp.add(editD);
138
     editD.addActionListener(new ActionListener() {
156
     editD.addActionListener(new ActionListener() {
139
       public void actionPerformed(ActionEvent evt) {
157
       public void actionPerformed(ActionEvent evt) {
140
-        editDActionPerformed(evt);
158
+        editD_ActionPerformed(evt);
141
       }
159
       }
142
     });
160
     });
143
 
161
 
144
     editE.setBounds(264, 136, 107, 25);
162
     editE.setBounds(264, 136, 107, 25);
145
     editE.setText("Layer E");
163
     editE.setText("Layer E");
164
+    editE.setFont(new Font("Dialog", Font.PLAIN, 13));
146
     cp.add(editE);
165
     cp.add(editE);
147
     editE.addActionListener(new ActionListener() {
166
     editE.addActionListener(new ActionListener() {
148
       public void actionPerformed(ActionEvent evt) {
167
       public void actionPerformed(ActionEvent evt) {
149
-        editEActionPerformed(evt);
168
+        editE_ActionPerformed(evt);
150
       }
169
       }
151
     });
170
     });
152
 
171
 
153
     editF.setBounds(264, 168, 107, 25);
172
     editF.setBounds(264, 168, 107, 25);
154
     editF.setText("Layer F");
173
     editF.setText("Layer F");
174
+    editF.setFont(new Font("Dialog", Font.PLAIN, 13));
155
     cp.add(editF);
175
     cp.add(editF);
156
     editF.addActionListener(new ActionListener() {
176
     editF.addActionListener(new ActionListener() {
157
       public void actionPerformed(ActionEvent evt) {
177
       public void actionPerformed(ActionEvent evt) {
158
-        editFActionPerformed(evt);
178
+        editF_ActionPerformed(evt);
159
       }
179
       }
160
     });
180
     });
161
 
181
 
162
     editG.setBounds(264, 200, 107, 25);
182
     editG.setBounds(264, 200, 107, 25);
163
     editG.setText("Layer G");
183
     editG.setText("Layer G");
184
+    editG.setFont(new Font("Dialog", Font.PLAIN, 13));
164
     cp.add(editG);
185
     cp.add(editG);
165
     editG.addActionListener(new ActionListener() {
186
     editG.addActionListener(new ActionListener() {
166
       public void actionPerformed(ActionEvent evt) {
187
       public void actionPerformed(ActionEvent evt) {
167
-        editGActionPerformed(evt);
188
+        editG_ActionPerformed(evt);
168
       }
189
       }
169
     });
190
     });
170
 
191
 
171
     editH.setBounds(264, 232, 107, 25);
192
     editH.setBounds(264, 232, 107, 25);
172
     editH.setText("Layer H");
193
     editH.setText("Layer H");
194
+    editH.setFont(new Font("Dialog", Font.PLAIN, 13));
173
     cp.add(editH);
195
     cp.add(editH);
174
     editH.addActionListener(new ActionListener() {
196
     editH.addActionListener(new ActionListener() {
175
       public void actionPerformed(ActionEvent evt) {
197
       public void actionPerformed(ActionEvent evt) {
176
-        editHActionPerformed(evt);
198
+        editH_ActionPerformed(evt);
177
       }
199
       }
178
     });
200
     });
179
 
201
 
180
-    frameList.setBounds(384, 8, 145, 249);
181
-    cp.add(frameList);
202
+    frameListScrollPane.setBounds(384, 8, 145, 249);
203
+    frameList.setModel(frameListModel);
204
+    //frameListModel.addElement();
205
+    cp.add(frameListScrollPane);
182
     frameUp.setBounds(544, 8, 107, 33);
206
     frameUp.setBounds(544, 8, 107, 33);
183
     frameUp.setText("Move up");
207
     frameUp.setText("Move up");
208
+    frameUp.setFont(new Font("Dialog", Font.PLAIN, 13));
184
     cp.add(frameUp);
209
     cp.add(frameUp);
185
     frameUp.addActionListener(new ActionListener() {
210
     frameUp.addActionListener(new ActionListener() {
186
       public void actionPerformed(ActionEvent evt) {
211
       public void actionPerformed(ActionEvent evt) {
187
-        frameUpActionPerformed(evt);
212
+        frameUp_ActionPerformed(evt);
188
       }
213
       }
189
     });
214
     });
190
 
215
 
191
     frameDown.setBounds(544, 152, 107, 33);
216
     frameDown.setBounds(544, 152, 107, 33);
192
     frameDown.setText("Move down");
217
     frameDown.setText("Move down");
218
+    frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
193
     cp.add(frameDown);
219
     cp.add(frameDown);
194
     frameDown.addActionListener(new ActionListener() {
220
     frameDown.addActionListener(new ActionListener() {
195
       public void actionPerformed(ActionEvent evt) {
221
       public void actionPerformed(ActionEvent evt) {
196
-        frameDownActionPerformed(evt);
222
+        frameDown_ActionPerformed(evt);
197
       }
223
       }
198
     });
224
     });
199
 
225
 
200
     frameAdd.setBounds(544, 56, 107, 33);
226
     frameAdd.setBounds(544, 56, 107, 33);
201
     frameAdd.setText("Add");
227
     frameAdd.setText("Add");
228
+    frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
202
     cp.add(frameAdd);
229
     cp.add(frameAdd);
203
     frameAdd.addActionListener(new ActionListener() {
230
     frameAdd.addActionListener(new ActionListener() {
204
       public void actionPerformed(ActionEvent evt) {
231
       public void actionPerformed(ActionEvent evt) {
205
-        frameAddActionPerformed(evt);
232
+        frameAdd_ActionPerformed(evt);
206
       }
233
       }
207
     });
234
     });
208
 
235
 
209
     frameRemove.setBounds(544, 104, 107, 33);
236
     frameRemove.setBounds(544, 104, 107, 33);
210
     frameRemove.setText("Remove");
237
     frameRemove.setText("Remove");
238
+    frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
211
     cp.add(frameRemove);
239
     cp.add(frameRemove);
212
     frameRemove.addActionListener(new ActionListener() {
240
     frameRemove.addActionListener(new ActionListener() {
213
       public void actionPerformed(ActionEvent evt) {
241
       public void actionPerformed(ActionEvent evt) {
214
-        frameRemoveActionPerformed(evt);
242
+        frameRemove_ActionPerformed(evt);
215
       }
243
       }
216
     });
244
     });
217
 
245
 
218
-    jList2.setBounds(8, 264, 209, 121);
219
-    cp.add(jList2);
246
+    jList2ScrollPane.setBounds(8, 264, 209, 121);
247
+    jList2.setModel(jList2Model);
248
+    //jList2Model.addElement("");
249
+    cp.add(jList2ScrollPane);
220
     animUp.setBounds(224, 264, 99, 25);
250
     animUp.setBounds(224, 264, 99, 25);
221
     animUp.setText("Move up");
251
     animUp.setText("Move up");
252
+    animUp.setFont(new Font("Dialog", Font.PLAIN, 13));
222
     cp.add(animUp);
253
     cp.add(animUp);
223
     animUp.addActionListener(new ActionListener() {
254
     animUp.addActionListener(new ActionListener() {
224
       public void actionPerformed(ActionEvent evt) {
255
       public void actionPerformed(ActionEvent evt) {
225
-        animUpActionPerformed(evt);
256
+        animUp_ActionPerformed(evt);
226
       }
257
       }
227
     });
258
     });
228
 
259
 
229
     animDown.setBounds(224, 360, 99, 25);
260
     animDown.setBounds(224, 360, 99, 25);
230
     animDown.setText("Move down");
261
     animDown.setText("Move down");
262
+    animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
231
     cp.add(animDown);
263
     cp.add(animDown);
232
     animDown.addActionListener(new ActionListener() {
264
     animDown.addActionListener(new ActionListener() {
233
       public void actionPerformed(ActionEvent evt) {
265
       public void actionPerformed(ActionEvent evt) {
234
-        animDownActionPerformed(evt);
266
+        animDown_ActionPerformed(evt);
235
       }
267
       }
236
     });
268
     });
237
 
269
 
238
     animAdd.setBounds(224, 296, 99, 25);
270
     animAdd.setBounds(224, 296, 99, 25);
239
     animAdd.setText("Add");
271
     animAdd.setText("Add");
272
+    animAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
240
     cp.add(animAdd);
273
     cp.add(animAdd);
241
     animAdd.addActionListener(new ActionListener() {
274
     animAdd.addActionListener(new ActionListener() {
242
       public void actionPerformed(ActionEvent evt) {
275
       public void actionPerformed(ActionEvent evt) {
243
-        animAddActionPerformed(evt);
276
+        animAdd_ActionPerformed(evt);
244
       }
277
       }
245
     });
278
     });
246
 
279
 
247
     animRemove.setBounds(224, 328, 99, 25);
280
     animRemove.setBounds(224, 328, 99, 25);
248
     animRemove.setText("Remove");
281
     animRemove.setText("Remove");
282
+    animRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
249
     cp.add(animRemove);
283
     cp.add(animRemove);
250
     animRemove.addActionListener(new ActionListener() {
284
     animRemove.addActionListener(new ActionListener() {
251
       public void actionPerformed(ActionEvent evt) {
285
       public void actionPerformed(ActionEvent evt) {
252
-        animRemoveActionPerformed(evt);
286
+        animRemove_ActionPerformed(evt);
253
       }
287
       }
254
     });
288
     });
255
 
289
 
256
     animPath.setBounds(344, 264, 305, 24);
290
     animPath.setBounds(344, 264, 305, 24);
257
     animPath.setEditable(false);
291
     animPath.setEditable(false);
258
     animPath.setText("Load/Save an animation file...");
292
     animPath.setText("Load/Save an animation file...");
293
+    animPath.setFont(new Font("Dialog", Font.PLAIN, 13));
259
     cp.add(animPath);
294
     cp.add(animPath);
260
     load.setBounds(344, 296, 147, 25);
295
     load.setBounds(344, 296, 147, 25);
261
     load.setText("Load");
296
     load.setText("Load");
297
+    load.setFont(new Font("Dialog", Font.PLAIN, 13));
262
     cp.add(load);
298
     cp.add(load);
263
     load.addActionListener(new ActionListener() {
299
     load.addActionListener(new ActionListener() {
264
       public void actionPerformed(ActionEvent evt) {
300
       public void actionPerformed(ActionEvent evt) {
265
-        loadActionPerformed(evt);
301
+        load_ActionPerformed(evt);
266
       }
302
       }
267
     });
303
     });
268
 
304
 
269
     save.setBounds(504, 296, 147, 25);
305
     save.setBounds(504, 296, 147, 25);
270
     save.setText("Save");
306
     save.setText("Save");
307
+    save.setFont(new Font("Dialog", Font.PLAIN, 13));
271
     cp.add(save);
308
     cp.add(save);
272
     save.addActionListener(new ActionListener() {
309
     save.addActionListener(new ActionListener() {
273
       public void actionPerformed(ActionEvent evt) {
310
       public void actionPerformed(ActionEvent evt) {
274
-        saveActionPerformed(evt);
311
+        save_ActionPerformed(evt);
275
       }
312
       }
276
     });
313
     });
277
 
314
 
278
     jComboBox1.setBounds(344, 328, 305, 24);
315
     jComboBox1.setBounds(344, 328, 305, 24);
316
+    jComboBox1.setFont(new Font("Dialog", Font.PLAIN, 13));
279
     cp.add(jComboBox1);
317
     cp.add(jComboBox1);
280
     upload.setBounds(344, 360, 147, 25);
318
     upload.setBounds(344, 360, 147, 25);
281
     upload.setText("Upload");
319
     upload.setText("Upload");
320
+    upload.setFont(new Font("Dialog", Font.PLAIN, 13));
282
     cp.add(upload);
321
     cp.add(upload);
283
     upload.addActionListener(new ActionListener() {
322
     upload.addActionListener(new ActionListener() {
284
       public void actionPerformed(ActionEvent evt) {
323
       public void actionPerformed(ActionEvent evt) {
285
-        uploadActionPerformed(evt);
324
+        upload_ActionPerformed(evt);
286
       }
325
       }
287
     });
326
     });
288
 
327
 
289
     download.setBounds(504, 360, 147, 25);
328
     download.setBounds(504, 360, 147, 25);
290
     download.setText("Download");
329
     download.setText("Download");
330
+    download.setFont(new Font("Dialog", Font.PLAIN, 13));
291
     cp.add(download);
331
     cp.add(download);
292
     download.addActionListener(new ActionListener() {
332
     download.addActionListener(new ActionListener() {
293
       public void actionPerformed(ActionEvent evt) {
333
       public void actionPerformed(ActionEvent evt) {
294
-        downloadActionPerformed(evt);
334
+        download_ActionPerformed(evt);
295
       }
335
       }
296
     });
336
     });
297
 
337
 
298
-    jLabel4.setBounds(536, 208, 111, 16);
338
+    jLabel4.setBounds(536, 208, 112, 20);
299
     jLabel4.setText("Frames remaining:");
339
     jLabel4.setText("Frames remaining:");
300
-    jLabel4.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
340
+    jLabel4.setFont(new Font("Dialog", Font.PLAIN, 13));
301
     cp.add(jLabel4);
341
     cp.add(jLabel4);
302
     frameRemaining.setBounds(536, 232, 113, 24);
342
     frameRemaining.setBounds(536, 232, 113, 24);
303
     frameRemaining.setEditable(false);
343
     frameRemaining.setEditable(false);
304
     frameRemaining.setText("2048");
344
     frameRemaining.setText("2048");
345
+    frameRemaining.setFont(new Font("Dialog", Font.PLAIN, 13));
305
     cp.add(frameRemaining);
346
     cp.add(frameRemaining);
347
+    jList2.setFont(new Font("Dialog", Font.PLAIN, 13));
348
+    frameList.setFont(new Font("Dialog", Font.PLAIN, 13));
306
     // Ende Komponenten
349
     // Ende Komponenten
307
 
350
 
308
     setResizable(false);
351
     setResizable(false);
309
     setVisible(true);
352
     setVisible(true);
310
   }
353
   }
311
 
354
 
355
+  // Anfang Methoden
356
+
312
   // Anfang Ereignisprozeduren
357
   // Anfang Ereignisprozeduren
313
-  public void editAActionPerformed(ActionEvent evt) {
358
+  public void editA_ActionPerformed(ActionEvent evt) {
314
 
359
 
315
   }
360
   }
316
 
361
 
317
-  public void editBActionPerformed(ActionEvent evt) {
362
+  public void editB_ActionPerformed(ActionEvent evt) {
318
 
363
 
319
   }
364
   }
320
 
365
 
321
-  public void editCActionPerformed(ActionEvent evt) {
366
+  public void editC_ActionPerformed(ActionEvent evt) {
322
 
367
 
323
   }
368
   }
324
 
369
 
325
-  public void editDActionPerformed(ActionEvent evt) {
370
+  public void editD_ActionPerformed(ActionEvent evt) {
326
 
371
 
327
   }
372
   }
328
 
373
 
329
-  public void editEActionPerformed(ActionEvent evt) {
374
+  public void editE_ActionPerformed(ActionEvent evt) {
330
 
375
 
331
   }
376
   }
332
 
377
 
333
-  public void editFActionPerformed(ActionEvent evt) {
378
+  public void editF_ActionPerformed(ActionEvent evt) {
334
 
379
 
335
   }
380
   }
336
 
381
 
337
-  public void editGActionPerformed(ActionEvent evt) {
382
+  public void editG_ActionPerformed(ActionEvent evt) {
338
 
383
 
339
   }
384
   }
340
 
385
 
341
-  public void editHActionPerformed(ActionEvent evt) {
386
+  public void editH_ActionPerformed(ActionEvent evt) {
342
 
387
 
343
   }
388
   }
344
 
389
 
345
-  public void frameUpActionPerformed(ActionEvent evt) {
390
+  public void frameUp_ActionPerformed(ActionEvent evt) {
346
          int i = frameList.getSelectedIndex();
391
          int i = frameList.getSelectedIndex();
347
          if ((i > 0) && (frameListModel.getSize() >= 2)) {
392
          if ((i > 0) && (frameListModel.getSize() >= 2)) {
348
             Object tmp = frameListModel.get(i);
393
             Object tmp = frameListModel.get(i);
352
          }
397
          }
353
   }
398
   }
354
 
399
 
355
-  public void frameDownActionPerformed(ActionEvent evt) {
400
+  public void frameDown_ActionPerformed(ActionEvent evt) {
356
          int i = frameList.getSelectedIndex();
401
          int i = frameList.getSelectedIndex();
357
          if ((i >= 0) && (frameListModel.getSize() >= 2) && (i < (frameListModel.getSize() - 1))) {
402
          if ((i >= 0) && (frameListModel.getSize() >= 2) && (i < (frameListModel.getSize() - 1))) {
358
             Object tmp = frameListModel.get(i);
403
             Object tmp = frameListModel.get(i);
362
          }
407
          }
363
   }
408
   }
364
 
409
 
365
-  public void frameAddActionPerformed(ActionEvent evt) {
366
-
410
+  public void frameAdd_ActionPerformed(ActionEvent evt) {
411
+         worker.addFrame();
412
+         frameRemaining.setText(Integer.toString(worker.framesRemaining()));
367
   }
413
   }
368
 
414
 
369
-  public void frameRemoveActionPerformed(ActionEvent evt) {
370
-
415
+  public void frameRemove_ActionPerformed(ActionEvent evt) {
416
+         worker.removeFrame(jList2.getSelectedIndex());
417
+         frameRemaining.setText(Integer.toString(worker.framesRemaining()));
371
   }
418
   }
372
 
419
 
373
-  public void animUpActionPerformed(ActionEvent evt) {
420
+  public void animUp_ActionPerformed(ActionEvent evt) {
374
          int i = jList2.getSelectedIndex();
421
          int i = jList2.getSelectedIndex();
375
-         if ((i > 0) && (animationListModel.getSize() >= 2)) {
376
-            Object tmp = animationListModel.get(i);
377
-            animationListModel.set(i, animationListModel.get(i - 1));
378
-            animationListModel.set(i - 1, tmp);
422
+         if ((i > 0) && (jList2Model.getSize() >= 2)) {
423
+            Object tmp = jList2Model.get(i);
424
+            jList2Model.set(i, jList2Model.get(i - 1));
425
+            jList2Model.set(i - 1, tmp);
379
             jList2.setSelectedIndex(i - 1);
426
             jList2.setSelectedIndex(i - 1);
380
          }
427
          }
381
   }
428
   }
382
 
429
 
383
-  public void animDownActionPerformed(ActionEvent evt) {
430
+  public void animDown_ActionPerformed(ActionEvent evt) {
384
          int i = jList2.getSelectedIndex();
431
          int i = jList2.getSelectedIndex();
385
-         if ((i >= 0) && (animationListModel.getSize() >= 2) && (i < (animationListModel.getSize() - 1))) {
386
-            Object tmp = animationListModel.get(i);
387
-            animationListModel.set(i, animationListModel.get(i + 1));
388
-            animationListModel.set(i + 1, tmp);
432
+         if ((i >= 0) && (jList2Model.getSize() >= 2) && (i < (jList2Model.getSize() - 1))) {
433
+            Object tmp = jList2Model.get(i);
434
+            jList2Model.set(i, jList2Model.get(i + 1));
435
+            jList2Model.set(i + 1, tmp);
389
             jList2.setSelectedIndex(i + 1);
436
             jList2.setSelectedIndex(i + 1);
390
          }
437
          }
391
   }
438
   }
392
 
439
 
393
-  public void animAddActionPerformed(ActionEvent evt) {
440
+  public void animAdd_ActionPerformed(ActionEvent evt) {
441
+    if(worker.addAnimation() == -1){
442
+      //show error Dialog
443
+    }
394
 
444
 
395
   }
445
   }
396
 
446
 
397
-  public void animRemoveActionPerformed(ActionEvent evt) {
398
-
447
+  public void animRemove_ActionPerformed(ActionEvent evt) {
448
+     worker.removeAnimation(jList2.getSelectedIndex());
399
   }
449
   }
400
 
450
 
401
-  public void loadActionPerformed(ActionEvent evt) {
402
-
451
+  public void load_ActionPerformed(ActionEvent evt) {
452
+    worker.loadState(animPath.getText());
403
   }
453
   }
404
 
454
 
405
-  public void saveActionPerformed(ActionEvent evt) {
406
-
455
+  public void save_ActionPerformed(ActionEvent evt) {
456
+    worker.saveState(animPath.getText());
407
   }
457
   }
408
 
458
 
409
 
459
 
410
-  public void uploadActionPerformed(ActionEvent evt) {
460
+  public void upload_ActionPerformed(ActionEvent evt) {
411
          if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
461
          if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
412
-            JOptionPane.showMessageDialog(this, "No serial port selected...");
462
+            errorMessage("No serial port selected...");
413
          } else {
463
          } else {
414
            worker.uploadState((String)jComboBox1.getSelectedItem());
464
            worker.uploadState((String)jComboBox1.getSelectedItem());
415
          }
465
          }
416
   }
466
   }
417
 
467
 
418
-  public void downloadActionPerformed(ActionEvent evt) {
468
+  public void download_ActionPerformed(ActionEvent evt) {
419
          if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
469
          if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
420
-            JOptionPane.showMessageDialog(this, "No serial port selected...");
470
+			errorMessage("No serial port selected...");
421
          } else {
471
          } else {
422
            worker.downloadState((String)jComboBox1.getSelectedItem());
472
            worker.downloadState((String)jComboBox1.getSelectedItem());
423
          }
473
          }
428
   public static void main(String[] args) {
478
   public static void main(String[] args) {
429
     new frame("Cube Control");
479
     new frame("Cube Control");
430
   }
480
   }
481
+  // Ende Methoden
431
 }
482
 }
432
 
483
 

+ 957
- 177
Cube Control/frame.jfm
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


Laddar…
Avbryt
Spara