Thomas Buck преди 12 години
родител
ревизия
5819b4c099
променени са 1 файла, в които са добавени 70 реда и са изтрити 46 реда
  1. 70
    46
      Cube Control/frame.java

+ 70
- 46
Cube Control/frame.java Целия файл

78
   private JTextField frameRemaining = new JTextField();
78
   private JTextField frameRemaining = new JTextField();
79
   private JLabel frmLngthLbl = new JLabel();
79
   private JLabel frmLngthLbl = new JLabel();
80
   private JTextField frmLngthTxt = new JTextField();
80
   private JTextField frmLngthTxt = new JTextField();
81
+  private JButton frameDuration = new JButton();
81
   // Ende Attribute
82
   // Ende Attribute
82
 
83
 
83
   private cubeWorker worker = new cubeWorker();
84
   private cubeWorker worker = new cubeWorker();
107
     if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
108
     if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
108
      int anim = animList.getSelectedIndex();
109
      int anim = animList.getSelectedIndex();
109
      int max;
110
      int max;
110
-   if (anim == -1){
111
+     if (anim == -1){
111
         anim = 0;
112
         anim = 0;
112
      }
113
      }
114
+	 if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
115
+	   	   frmLngthTxt.setText(Integer.toString(worker.getFrameTime(animList.getSelectedIndex(), frameList.getSelectedIndex())));
116
+	 }
113
      if(evt.getSource() == frameList){
117
      if(evt.getSource() == frameList){
114
        max = worker.numOfAnimations();
118
        max = worker.numOfAnimations();
115
-     animModel.clear();
119
+	   animModel.clear();
116
      } else {
120
      } else {
117
        max = worker.numOfFrames(anim);
121
        max = worker.numOfFrames(anim);
118
-     frameListModel.clear();
122
+       frameListModel.clear();
119
      }
123
      }
120
 
124
 
121
    // if value changed in anim, rebuild frame, else other way round
125
    // if value changed in anim, rebuild frame, else other way round
285
 
289
 
286
     frameListScrollPane.setBounds(384, 8, 145, 249);
290
     frameListScrollPane.setBounds(384, 8, 145, 249);
287
     frameList.setModel(frameListModel);
291
     frameList.setModel(frameListModel);
288
-    //frameListModel.addElement();
289
     cp.add(frameListScrollPane);
292
     cp.add(frameListScrollPane);
290
 
293
 
291
     frameUp.setBounds(544, 8, 107, 28);
294
     frameUp.setBounds(544, 8, 107, 28);
298
       }
301
       }
299
     });
302
     });
300
 
303
 
301
-    frameDown.setBounds(544, 122, 107, 28);
302
-
303
-    frameDown.setText("Move down");
304
-    frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
305
-    cp.add(frameDown);
306
-    frameDown.addActionListener(new ActionListener() {
304
+	frameAdd.setBounds(544, 39, 107, 28);
305
+    frameAdd.setText("Add");
306
+    frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
307
+    cp.add(frameAdd);
308
+    frameAdd.addActionListener(new ActionListener() {
307
       public void actionPerformed(ActionEvent evt) {
309
       public void actionPerformed(ActionEvent evt) {
308
-        frameDown_ActionPerformed(evt);
310
+        frameAdd_ActionPerformed(evt);
309
       }
311
       }
310
     });
312
     });
311
 
313
 
312
-    frameAdd.setBounds(544, 46, 107, 28);
313
-  frameRename.setText("Rename");
314
-  frameRename.setFont(new Font("Dialog", Font.PLAIN, 13));
315
-  cp.add(frameRename);
316
-  frameRename.addActionListener(new ActionListener() {
314
+	frameRemove.setBounds(544, 70, 107, 28);
315
+    frameRemove.setText("Remove");
316
+    frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
317
+    cp.add(frameRemove);
318
+    frameRemove.addActionListener(new ActionListener() {
319
+      public void actionPerformed(ActionEvent evt) {
320
+        frameRemove_ActionPerformed(evt);
321
+      }
322
+    });
323
+	
324
+	frameRename.setBounds(544, 101, 107, 28);
325
+	frameRename.setText("Rename");
326
+  	frameRename.setFont(new Font("Dialog", Font.PLAIN, 13));
327
+  	cp.add(frameRename);
328
+  	frameRename.addActionListener(new ActionListener() {
317
     public void actionPerformed(ActionEvent evt) {
329
     public void actionPerformed(ActionEvent evt) {
318
       int a = animList.getSelectedIndex();
330
       int a = animList.getSelectedIndex();
319
       if (a < 0) {
331
       if (a < 0) {
331
     }
343
     }
332
   });
344
   });
333
 
345
 
334
-
335
-    frameAdd.setText("Add");
336
-    frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
337
-    cp.add(frameAdd);
338
-    frameAdd.addActionListener(new ActionListener() {
339
-      public void actionPerformed(ActionEvent evt) {
340
-        frameAdd_ActionPerformed(evt);
341
-      }
342
-    });
343
-
344
-
345
-    frameRemove.setBounds(544, 84, 107, 28);
346
-
347
-    frameRemove.setBounds(544, 84, 107, 33);
348
-
349
-    frameRemove.setText("Remove");
350
-    frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
351
-    cp.add(frameRemove);
352
-    frameRemove.addActionListener(new ActionListener() {
346
+    frameDown.setBounds(544, 132, 107, 28);
347
+    frameDown.setText("Move down");
348
+    frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
349
+    cp.add(frameDown);
350
+    frameDown.addActionListener(new ActionListener() {
353
       public void actionPerformed(ActionEvent evt) {
351
       public void actionPerformed(ActionEvent evt) {
354
-        frameRemove_ActionPerformed(evt);
352
+        frameDown_ActionPerformed(evt);
355
       }
353
       }
356
     });
354
     });
357
 
355
 
358
     frmLngthLbl.setBounds(536, 160, 113, 24);
356
     frmLngthLbl.setBounds(536, 160, 113, 24);
359
-    frmLngthLbl.setText("Length of a frame");
357
+    frmLngthLbl.setText("Time (1/24 sec)");
360
     frmLngthLbl.setFont(new Font("Dialog", Font.PLAIN, 13));
358
     frmLngthLbl.setFont(new Font("Dialog", Font.PLAIN, 13));
361
     cp.add(frmLngthLbl);
359
     cp.add(frmLngthLbl);
362
 
360
 
363
-    frmLngthTxt.setBounds(536, 184, 113, 24);
364
-    frmLngthTxt.setText("0");
361
+    frmLngthTxt.setBounds(536, 184, 50, 24);
362
+    frmLngthTxt.setText("");
365
     frmLngthTxt.setFont(new Font("Dialog", Font.PLAIN, 13));
363
     frmLngthTxt.setFont(new Font("Dialog", Font.PLAIN, 13));
366
     cp.add(frmLngthTxt);
364
     cp.add(frmLngthTxt);
367
 
365
 
366
+	frameDuration.setBounds(590, 184, 50, 24);
367
+	frameDuration.setText("OK");
368
+	frameDuration.setFont(new Font("Dialog", Font.PLAIN, 13));
369
+	cp.add(frameDuration);
370
+	frameDuration.addActionListener(new ActionListener() {
371
+		public void actionPerformed(ActionEvent evt) {
372
+			if (frmLngthTxt.getText().equals("0")) {
373
+				errorMessage("0 is not a valid value!");
374
+				frmLngthTxt.setText("1");
375
+			} else if (Integer.parseInt(frmLngthTxt.getText()) > 256) {
376
+				errorMessage("Value too high. Max: 256");
377
+				frmLngthTxt.setText("256");
378
+				return;
379
+			} else {
380
+				if (animList.getSelectedIndex() == -1) {
381
+					errorMessage("Please select an animation!");
382
+					return;
383
+				}
384
+				if (frameList.getSelectedIndex() == -1) {
385
+					errorMessage("Please select a frame!");
386
+					return;
387
+				}
388
+				worker.setFrameTime((byte)(Integer.parseInt(frmLngthTxt.getText()) - 1), animList.getSelectedIndex(), frameList.getSelectedIndex());
389
+			}
390
+		}
391
+	});
392
+
368
     animScrollPane.setBounds(8, 264, 209, 121);
393
     animScrollPane.setBounds(8, 264, 209, 121);
369
     animList.setModel(animModel);
394
     animList.setModel(animModel);
370
-    //jList2Model.addElement("");
371
     cp.add(animScrollPane);
395
     cp.add(animScrollPane);
372
 
396
 
373
     animUp.setBounds(224, 264, 99, 25);
397
     animUp.setBounds(224, 264, 99, 25);
380
       }
404
       }
381
     });
405
     });
382
 
406
 
383
-    animDown.setBounds(224, 342, 99, 25);
407
+  	animDown.setBounds(224, 368, 99, 25);
384
     animDown.setText("Move down");
408
     animDown.setText("Move down");
385
     animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
409
     animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
386
     cp.add(animDown);
410
     cp.add(animDown);
390
       }
414
       }
391
     });
415
     });
392
 
416
 
393
-  animRename.setBounds(224, 368, 99, 25);
394
-  animRename.setText("Rename");
395
-  animRename.setFont(new Font("Dialog", Font.PLAIN, 13));
396
-  cp.add(animRename);
397
-  animRename.addActionListener(new ActionListener() {
417
+    animRename.setBounds(224, 342, 99, 25);
418
+  	animRename.setText("Rename");
419
+  	animRename.setFont(new Font("Dialog", Font.PLAIN, 13));
420
+  	cp.add(animRename);
421
+  	animRename.addActionListener(new ActionListener() {
398
     public void actionPerformed(ActionEvent evt) {
422
     public void actionPerformed(ActionEvent evt) {
399
       int a = animList.getSelectedIndex();
423
       int a = animList.getSelectedIndex();
400
       if (a < 0) {
424
       if (a < 0) {

Loading…
Отказ
Запис