Browse Source

Added slider for setting frame duration

hutattedonmyarm 12 years ago
parent
commit
feba4d2f81
1 changed files with 30 additions and 16 deletions
  1. 30
    16
      CubeControl/Frame.java

+ 30
- 16
CubeControl/Frame.java View File

@@ -32,7 +32,7 @@ import javax.vecmath.Point2d;
32 32
 import javax.vecmath.Point3d;
33 33
 import java.util.Arrays;
34 34
 
35
-public class Frame extends JFrame implements ListSelectionListener {
35
+public class Frame extends JFrame implements ListSelectionListener, ChangeListener{
36 36
 
37 37
 	private static final long serialVersionUID = 23421337L;
38 38
 	// Anfang Variablen
@@ -88,6 +88,8 @@ public class Frame extends JFrame implements ListSelectionListener {
88 88
 	private JPanel filePanel = new JPanel();
89 89
 	private JPanel serialPanel = new JPanel();
90 90
 	private JPanel settingsPanel = new JPanel();
91
+	private JSlider durationSlider = new JSlider(1, 256 ,1); //min, max, value
92
+
91 93
 
92 94
 	// Ende Attribute
93 95
 	
@@ -210,6 +212,11 @@ public class Frame extends JFrame implements ListSelectionListener {
210 212
 			}
211 213
 		}
212 214
 	}
215
+
216
+	public void stateChanged(ChangeEvent e){
217
+			frameLengthText.setText(durationSlider.getValue() + "");
218
+		
219
+	}
213 220
 	
214 221
 	private void save() {
215 222
 		if (fileSelected == false) {
@@ -507,15 +514,7 @@ public class Frame extends JFrame implements ListSelectionListener {
507 514
 			}
508 515
 		});
509 516
 
510
-		frameLengthLabel.setBounds(429, 118, 90, 13);
511
-		frameLengthLabel.setText("Time (1/24 sec)");
512
-		frameLengthLabel.setFont(font);
513
-		cp.add(frameLengthLabel);
514
-	
515
-		frameLengthText.setBounds(429, 134, 31, 20);
516
-		frameLengthText.setFont(font);
517
-		cp.add(frameLengthText);
518
-		
517
+			
519 518
 		fullScreenButton.setText("Fullscreen");
520 519
 		fullScreenButton.setBounds(18, 312, 134, 35);
521 520
 		fullScreenButton.setFont(font);
@@ -602,7 +601,7 @@ public class Frame extends JFrame implements ListSelectionListener {
602 601
 			}
603 602
 		});
604 603
 	
605
-		frameDuration.setBounds(462, 134, 55, 20);
604
+		frameDuration.setBounds(462, 129, 55, 20);
606 605
 		frameDuration.setText("OK");
607 606
 		frameDuration.setFont(font);
608 607
 		cp.add(frameDuration);
@@ -624,6 +623,7 @@ public class Frame extends JFrame implements ListSelectionListener {
624 623
 						errorMessage("Please select a Frame!");
625 624
 						return;
626 625
 					}
626
+					durationSlider.setValue(Integer.parseInt(frameLengthText.getText()));
627 627
 					worker.getAnimation(animList.getSelectedIndex()).getFrame(frameList.getSelectedIndex()).setTime((byte)(Integer.parseInt(frameLengthText.getText())));
628 628
 				}
629 629
 			}
@@ -708,7 +708,7 @@ public class Frame extends JFrame implements ListSelectionListener {
708 708
 			}
709 709
 		});
710 710
 
711
-		serialPortSelector.setBounds(417, 186, 228, 21);
711
+		serialPortSelector.setBounds(417, 182, 228, 25);
712 712
 		serialPortSelector.setFont(font);
713 713
 		cp.add(serialPortSelector);
714 714
 
@@ -738,12 +738,26 @@ public class Frame extends JFrame implements ListSelectionListener {
738 738
 			}
739 739
 		});
740 740
 	
741
-		remainingLabel.setBounds(530, 118, 90, 13);
741
+		frameLengthLabel.setBounds(420, 97, 130, 13);
742
+		frameLengthLabel.setText("Time (1/24 sec)");
743
+		frameLengthLabel.setFont(font);
744
+		cp.add(frameLengthLabel);
745
+	
746
+		frameLengthText.setBounds(419, 129, 36, 20);
747
+		frameLengthText.setFont(font);
748
+		cp.add(frameLengthText);
749
+
750
+
751
+		remainingLabel.setBounds(530, 113, 90, 13);
742 752
 		remainingLabel.setText("Remaining:");
743 753
 		remainingLabel.setFont(font);
744 754
 		cp.add(remainingLabel);
755
+
756
+		durationSlider.setBounds(417, 108, 110, 23);
757
+		durationSlider.addChangeListener(this);
758
+		cp.add(durationSlider);
745 759
 		
746
-		frameRemaining.setBounds(530, 134, 49, 20);
760
+		frameRemaining.setBounds(530, 129, 49, 20);
747 761
 		frameRemaining.setEditable(false);
748 762
 		frameRemaining.setText(String.valueOf(worker.memoryRemaining()));
749 763
 		frameRemaining.setFont(font);
@@ -767,11 +781,11 @@ public class Frame extends JFrame implements ListSelectionListener {
767 781
 		filePanel.setBorder(BorderFactory.createTitledBorder("Load/Save"));
768 782
 		cp.add(filePanel);
769 783
 	
770
-		serialPanel.setBounds(409, 167, 243, 92);
784
+		serialPanel.setBounds(409, 160, 243, 99);
771 785
 		serialPanel.setBorder(BorderFactory.createTitledBorder("Serial communication"));
772 786
 		cp.add(serialPanel);
773 787
 	
774
-		settingsPanel.setBounds(409, 100, 243, 65);
788
+		settingsPanel.setBounds(409, 75, 243, 82);
775 789
 		settingsPanel.setBorder(BorderFactory.createTitledBorder("Frame duration"));
776 790
 		cp.add(settingsPanel);
777 791
 	

Loading…
Cancel
Save