src/java.desktop/share/classes/javax/swing/JSlider.java

Print this page

        

@@ -20,11 +20,10 @@
  *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package javax.swing;
 
 import javax.swing.event.*;
 import javax.swing.plaf.*;
 import javax.accessibility.*;

@@ -33,12 +32,14 @@
 import java.io.ObjectOutputStream;
 import java.io.IOException;
 
 import java.awt.*;
 import java.util.*;
-import java.beans.*;
-
+import java.beans.JavaBean;
+import java.beans.BeanProperty;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 
 /**
  * A component that lets the user graphically select a value by sliding
  * a knob within a bounded interval. The knob is always positioned
  * at the points that match integer values within the specified interval.

@@ -70,17 +71,15 @@
  * the same version of Swing.  As of 1.4, support for long term storage
  * of all JavaBeans™
  * has been added to the <code>java.beans</code> package.
  * Please see {@link java.beans.XMLEncoder}.
  *
- * @beaninfo
- *      attribute: isContainer false
- *    description: A component that supports selecting a integer value from a range.
- *
  * @author David Kloba
  * @since 1.2
  */
+@JavaBean(defaultProperty = "UI", description = "A component that supports selecting a integer value from a range.")
+@SwingContainer(false)
 @SuppressWarnings("serial") // Same-version serialization only
 public class JSlider extends JComponent implements SwingConstants, Accessible {
     /**
      * @see #getUIClassID
      * @see #readObject

@@ -308,16 +307,13 @@
     /**
      * Sets the UI object which implements the L&amp;F for this component.
      *
      * @param ui the SliderUI L&amp;F object
      * @see UIDefaults#getUI
-     * @beaninfo
-     *        bound: true
-     *       hidden: true
-     *    attribute: visualUpdate true
-     *  description: The UI object that implements the slider's LookAndFeel.
      */
+    @BeanProperty(hidden = true, visualUpdate = true, description
+            = "The UI object that implements the slider's LookAndFeel.")
     public void setUI(SliderUI ui) {
         super.setUI(ui);
     }
 
 

@@ -341,10 +337,11 @@
      *
      * @return "SliderUI"
      * @see JComponent#getUIClassID
      * @see UIDefaults#getUI
      */
+    @BeanProperty(bound = false)
     public String getUIClassID() {
         return uiClassID;
     }
 
 

@@ -411,10 +408,11 @@
      *
      * @return all of the <code>ChangeListener</code>s added or an empty
      *         array if no listeners have been added
      * @since 1.4
      */
+    @BeanProperty(bound = false)
     public ChangeListener[] getChangeListeners() {
         return listenerList.getListeners(ChangeListener.class);
     }
 
 

@@ -466,14 +464,13 @@
      *
      * @param  newModel the new, {@code non-null} <code>BoundedRangeModel</code> to use
      *
      * @see #getModel
      * @see    BoundedRangeModel
-     * @beaninfo
-     *       bound: true
-     * description: The sliders BoundedRangeModel.
      */
+    @BeanProperty(description
+            = "The sliders BoundedRangeModel.")
     public void setModel(BoundedRangeModel newModel)
     {
         BoundedRangeModel oldModel = getModel();
 
         if (oldModel != null) {

@@ -525,14 +522,13 @@
      *
      * @param   n       the new value
      * @see     #getValue
      * @see     #addChangeListener
      * @see     BoundedRangeModel#setValue
-     * @beaninfo
-     *   preferred: true
-     * description: The sliders current value.
      */
+    @BeanProperty(bound = false, preferred = true, description
+            = "The sliders current value.")
     public void setValue(int n) {
         BoundedRangeModel m = getModel();
         int oldValue = m.getValue();
         if (oldValue == n) {
             return;

@@ -575,15 +571,13 @@
      *
      * @param minimum  the new minimum
      * @see #getMinimum
      * @see    #addChangeListener
      * @see BoundedRangeModel#setMinimum
-     * @beaninfo
-     *       bound: true
-     *   preferred: true
-     * description: The sliders minimum value.
      */
+    @BeanProperty(preferred = true, description
+            = "The sliders minimum value.")
     public void setMinimum(int minimum) {
         int oldMin = getModel().getMinimum();
         getModel().setMinimum(minimum);
         firePropertyChange( "minimum", Integer.valueOf( oldMin ), Integer.valueOf( minimum ) );
     }

@@ -616,15 +610,13 @@
      *
      * @param maximum  the new maximum
      * @see #getMaximum
      * @see #addChangeListener
      * @see BoundedRangeModel#setMaximum
-     * @beaninfo
-     *       bound: true
-     *   preferred: true
-     * description: The sliders maximum value.
      */
+    @BeanProperty(preferred = true, description
+            = "The sliders maximum value.")
     public void setMaximum(int maximum) {
         int oldMax = getModel().getMaximum();
         getModel().setMaximum(maximum);
         firePropertyChange( "maximum", Integer.valueOf( oldMax ), Integer.valueOf( maximum ) );
     }

@@ -649,14 +641,13 @@
      * a knob drag begins, and to {@code false} when the drag ends.
      *
      * @param b the new value for the {@code valueIsAdjusting} property
      * @see   #getValueIsAdjusting
      * @see   BoundedRangeModel#setValueIsAdjusting
-     * @beaninfo
-     *      expert: true
-     * description: True if the slider knob is being dragged.
      */
+    @BeanProperty(bound = false, expert = true, description
+            = "True if the slider knob is being dragged.")
     public void setValueIsAdjusting(boolean b) {
         BoundedRangeModel m = getModel();
         boolean oldValue = m.getValueIsAdjusting();
         m.setValueIsAdjusting(b);
 

@@ -697,14 +688,13 @@
      * all change listeners are notified.
      *
      * @param extent the new extent
      * @see   #getExtent
      * @see   BoundedRangeModel#setExtent
-     * @beaninfo
-     *      expert: true
-     * description: Size of the range covered by the knob.
      */
+    @BeanProperty(bound = false, expert = true, description
+            = "Size of the range covered by the knob.")
     public void setExtent(int extent) {
         getModel().setExtent(extent);
     }
 
 

@@ -724,19 +714,15 @@
      * {@code SwingConstants.HORIZONTAL}.
      *
      * @param orientation {@code HORIZONTAL} or {@code VERTICAL}
      * @throws IllegalArgumentException if orientation is not one of {@code VERTICAL}, {@code HORIZONTAL}
      * @see #getOrientation
-     * @beaninfo
-     *    preferred: true
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: Set the scrollbars orientation to either VERTICAL or HORIZONTAL.
-     *         enum: VERTICAL JSlider.VERTICAL
-     *               HORIZONTAL JSlider.HORIZONTAL
-     *
      */
+    @BeanProperty(preferred = true, visualUpdate = true, enumerationValues = {
+            "JSlider.VERTICAL",
+            "JSlider.HORIZONTAL"}, description
+            = "Set the scrollbars orientation to either VERTICAL or HORIZONTAL.")
     public void setOrientation(int orientation)
     {
         checkOrientation(orientation);
         int oldValue = this.orientation;
         this.orientation = orientation;

@@ -826,16 +812,13 @@
      * @param labels new {@code Dictionary} of labels, or {@code null} to
      *        remove all labels
      * @see #createStandardLabels(int)
      * @see #getLabelTable
      * @see #setPaintLabels
-     * @beaninfo
-     *       hidden: true
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: Specifies what labels will be drawn for any given value.
      */
+    @BeanProperty(hidden = true, visualUpdate = true, description
+            = "Specifies what labels will be drawn for any given value.")
     @SuppressWarnings("rawtypes")
     public void setLabelTable( Dictionary labels ) {
         Dictionary oldTable = labelTable;
         labelTable = labels;
         updateLabelUIs();

@@ -1060,16 +1043,13 @@
      * slider is inverted.
      * <p>
      * By default, the value of this property is {@code false}.
      *
      * @param b  true to reverse the slider values from their normal order
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: If true reverses the slider values from their normal order
-     *
      */
+    @BeanProperty(visualUpdate = true, description
+            = "If true reverses the slider values from their normal order")
     public void setInverted( boolean b ) {
         boolean oldValue = isInverted;
         isInverted = b;
         firePropertyChange("inverted", oldValue, isInverted);
         if (b != oldValue) {

@@ -1116,16 +1096,13 @@
      * @param  n  new value for the {@code majorTickSpacing} property
      * @see #getMajorTickSpacing
      * @see #setPaintTicks
      * @see #setLabelTable
      * @see #createStandardLabels(int)
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: Sets the number of values between major tick marks.
-     *
      */
+    @BeanProperty(visualUpdate = true, description
+            = "Sets the number of values between major tick marks.")
     public void setMajorTickSpacing(int n) {
         int oldValue = majorTickSpacing;
         majorTickSpacing = n;
         if ( labelTable == null && getMajorTickSpacing() > 0 && getPaintLabels() ) {
             setLabelTable( createStandardLabels( getMajorTickSpacing() ) );

@@ -1164,15 +1141,13 @@
      * set to {@code true}.
      *
      * @param  n  new value for the {@code minorTickSpacing} property
      * @see #getMinorTickSpacing
      * @see #setPaintTicks
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: Sets the number of values between minor tick marks.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "Sets the number of values between minor tick marks.")
     public void setMinorTickSpacing(int n) {
         int oldValue = minorTickSpacing;
         minorTickSpacing = n;
         firePropertyChange("minorTickSpacing", oldValue, minorTickSpacing);
         if (minorTickSpacing != oldValue && getPaintTicks()) {

@@ -1213,14 +1188,13 @@
      * positioned the knob.
      * By default, this property is {@code false}.
      *
      * @param b  true to snap the knob to the nearest tick mark
      * @see #getSnapToTicks
-     * @beaninfo
-     *       bound: true
-     * description: If true snap the knob to the nearest tick mark.
      */
+    @BeanProperty(description
+            = "If true snap the knob to the nearest tick mark.")
     public void setSnapToTicks(boolean b) {
         boolean oldValue = snapToTicks;
         snapToTicks = b;
         firePropertyChange("snapToTicks", oldValue, snapToTicks);
     }

@@ -1234,14 +1208,13 @@
      * By default, the snapToValue property is {@code true}.
      *
      * @param b  true to snap the knob to the nearest slider value
      * @see #getSnapToValue
      * @see #setSnapToTicks
-     * @beaninfo
-     *       bound: true
-     * description: If true snap the knob to the nearest slider value.
      */
+    @BeanProperty(description
+            = "If true snap the knob to the nearest slider value.")
     void setSnapToValue(boolean b) {
         boolean oldValue = snapToValue;
         snapToValue = b;
         firePropertyChange("snapToValue", oldValue, snapToValue);
     }

@@ -1261,15 +1234,13 @@
      * Determines whether tick marks are painted on the slider.
      * By default, this property is {@code false}.
      *
      * @param  b  whether or not tick marks should be painted
      * @see #getPaintTicks
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: If true tick marks are painted on the slider.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "If true tick marks are painted on the slider.")
     public void setPaintTicks(boolean b) {
         boolean oldValue = paintTicks;
         paintTicks = b;
         firePropertyChange("paintTicks", oldValue, paintTicks);
         if (paintTicks != oldValue) {

@@ -1292,15 +1263,13 @@
      * property is {@code true}. It is up to the look and feel to honor this
      * property, some may choose to ignore it.
      *
      * @param  b  whether or not to paint the slider track
      * @see #getPaintTrack
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: If true, the track is painted on the slider.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "If true, the track is painted on the slider.")
     public void setPaintTrack(boolean b) {
         boolean oldValue = paintTrack;
         paintTrack = b;
         firePropertyChange("paintTrack", oldValue, paintTrack);
         if (paintTrack != oldValue) {

@@ -1334,15 +1303,13 @@
      *
      * @param  b  whether or not to paint labels
      * @see #getPaintLabels
      * @see #getLabelTable
      * @see #createStandardLabels(int)
-     * @beaninfo
-     *        bound: true
-     *    attribute: visualUpdate true
-     *  description: If true labels are painted on the slider.
      */
+    @BeanProperty(visualUpdate = true, description
+            = "If true labels are painted on the slider.")
     public void setPaintLabels(boolean b) {
         boolean oldValue = paintLabels;
         paintLabels = b;
         if ( labelTable == null && getMajorTickSpacing() > 0 ) {
             setLabelTable( createStandardLabels( getMajorTickSpacing() ) );

@@ -1420,10 +1387,11 @@
      * A new AccessibleJSlider instance is created if necessary.
      *
      * @return an AccessibleJSlider that serves as the
      *         AccessibleContext of this JSlider
      */
+    @BeanProperty(bound = false)
     public AccessibleContext getAccessibleContext() {
         if (accessibleContext == null) {
             accessibleContext = new AccessibleJSlider();
         }
         return accessibleContext;