]> ruin.nu Git - moosique.git/commitdiff
trying to create int validation..
authorMichael Andreen <harv@ruin.nu>
Mon, 12 May 2003 10:14:27 +0000 (10:14 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 12 May 2003 10:14:27 +0000 (10:14 +0000)
MooNoteProp.java

index cc3c192855c5a7a7aa42e3039c6bc6900bbeb1b7..8eb36fea5e1ddbd8fb81498ddcba042db3cddaeb 100644 (file)
@@ -60,13 +60,24 @@ public class MooNoteProp extends JDialog{
                                     options[0]);
         setContentPane(optionPane);
         setDefaultCloseOperation(EXIT_ON_CLOSE);
-/*
-        textField.addActionListener(new ActionListener() {
+
+        ActionListener intValidator = new ActionListener() {
             public void actionPerformed(ActionEvent e) {
-                optionPane.setValue(btnString1);
+                               if (e.getSource() instanceof JTextField){
+                                       JTextField s = (JTextField)e.getSource();
+                                       int num = Integer.parseInt(s.getText());
+                                       if (num < 0)
+                                               num = 0;
+                                       else if (num > 127 && s != length)
+                                               num = 127;
+                                       s.setText(new Integer(num).toString());
+                               }
             }
-        });
-*/
+        };
+               pitch.addActionListener(intValidator);
+               velocity.addActionListener(intValidator);
+               length.addActionListener(intValidator);
+
         optionPane.addPropertyChangeListener(new PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent e) {
                 String prop = e.getPropertyName();