OSDN Git Service

2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / JSpinner.java
index 00b22d5..271c511 100644 (file)
@@ -35,20 +35,18 @@ this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package javax.swing;
 
-import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.LayoutManager;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.text.DecimalFormat;
 import java.text.ParseException;
-import java.util.EventListener;
+
 import javax.swing.border.EtchedBorder;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -113,21 +111,41 @@ public class JSpinner extends JComponent
                                                               PropertyChangeListener,
                                                               LayoutManager
   {
+    private JSpinner spinner;
+    
+    /**
+     * For compatability with Sun's JDK 1.4.2 rev. 5
+     */
+    private static final long serialVersionUID = -5317788736173368172L;
+
     /**
-     * Creates a new DefaultEditor object.
+     * Creates a new <code>DefaultEditor</code> object.
      *
-     * @param spinner DOCUMENT ME!
+     * @param spinner the <code>JSpinner</code> associated with this editor
      */
     public DefaultEditor(JSpinner spinner)
     {
+      this.spinner = spinner;
+      
       spinner.addChangeListener(this);
-    } /* TODO */
+    }
+
+    /**
+     * Returns the <code>JSpinner</code> object for this editor.
+     */
+    public JSpinner getSpinner()
+    {
+      return spinner;
+    }
+    
     /**
      * DOCUMENT ME!
      */
     public void commitEdit()
+      throws ParseException
     {
     } /* TODO */
+
     /**
      * DOCUMENT ME!
      *
@@ -147,6 +165,7 @@ public class JSpinner extends JComponent
     {
       return null;
     } /* TODO */
+    
     /**
      * DOCUMENT ME!
      *
@@ -155,6 +174,7 @@ public class JSpinner extends JComponent
     public void layoutContainer(Container parent)
     {
     } /* TODO */
+    
     /**
      * DOCUMENT ME!
      *
@@ -166,6 +186,7 @@ public class JSpinner extends JComponent
     {
       return null;
     } /* TODO */
+    
     /**
      * DOCUMENT ME!
      *
@@ -177,22 +198,25 @@ public class JSpinner extends JComponent
     {
       return null;
     } /* TODO */
+    
     /**
      * DOCUMENT ME!
      *
-     * @param evt DOCUMENT ME!
+     * @param event DOCUMENT ME!
      */
-    public void propertyChange(PropertyChangeEvent evt)
+    public void propertyChange(PropertyChangeEvent event)
     {
     } /* TODO */
+    
     /**
      * DOCUMENT ME!
      *
-     * @param evt DOCUMENT ME!
+     * @param event DOCUMENT ME!
      */
-    public void stateChanged(ChangeEvent evt)
+    public void stateChanged(ChangeEvent event)
     {
     } /* TODO */
+    
     /* no-ops */
     public void removeLayoutComponent(Component child)
     {
@@ -215,6 +239,11 @@ public class JSpinner extends JComponent
   public static class NumberEditor extends DefaultEditor
   {
     /**
+     * For compatability with Sun's JDK
+     */
+    private static final long serialVersionUID = 3791956183098282942L;
+
+    /**
      * Creates a new NumberEditor object.
      *
      * @param spinner DOCUMENT ME!
@@ -225,6 +254,16 @@ public class JSpinner extends JComponent
     }
 
     /**
+     * Creates a new NumberEditor object.
+     *
+     * @param spinner DOCUMENT ME!
+     */
+    public NumberEditor(JSpinner spinner, String decimalFormatPattern)
+    {
+      super(spinner);
+    }
+
+    /**
      * DOCUMENT ME!
      *
      * @return DOCUMENT ME!
@@ -233,6 +272,11 @@ public class JSpinner extends JComponent
     {
       return null;
     }
+
+    public SpinnerNumberModel getModel()
+    {
+      return (SpinnerNumberModel) getSpinner().getModel();
+    }
   }
 
   /** DOCUMENT ME! */
@@ -337,6 +381,29 @@ public class JSpinner extends JComponent
   }
 
   /**
+   * Sets a new underlying model.
+   *
+   * @param newModel the new model to set
+   *
+   * @exception IllegalArgumentException if newModel is <code>null</code>
+   */
+  public void setModel(SpinnerModel newModel)
+  {
+    if (newModel == null)
+      throw new IllegalArgumentException();
+    
+    if (model == newModel)
+      return;
+
+    SpinnerModel oldModel = model;
+    model = newModel;
+    firePropertyChange("model", oldModel, newModel);
+
+    if (editor == null)
+      setEditor(createEditor(model));
+  }
+
+  /**
    * Gets the next value without changing the current value.
    *
    * @return the next value