GNU Classpath (0.20) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSlider
public class JSlider
extends JComponent
implements SwingConstants, Accessible, ImageObserver, MenuContainer, Serializable
DefaultBoundedRangeModel
.
JSliders have the following properties:
Property | Stored in | Bound? |
---|---|---|
extent | model | no |
inverted | slider | yes |
labelTable | slider | yes |
majorTickSpacing | slider | yes |
maximum | model | no |
minimum | model | no |
minorTickSpacing | slider | yes |
model | slider | yes |
orientation | slider | yes |
paintLabels | slider | yes |
paintTicks | slider | yes |
snapToTicks | slider | no |
value | model | no |
valueIsAdjusting | model | no |
Nested Class Summary | |
protected class |
|
Nested classes/interfaces inherited from class javax.swing.JComponent | |
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container | |
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component | |
Component.AccessibleAWTComponent , Component.BltBufferStrategy , Component.FlipBufferStrategy |
Field Summary | |
protected ChangeEvent |
|
protected ChangeListener |
|
protected int |
|
protected int |
|
protected int |
|
protected BoundedRangeModel |
|
protected boolean |
|
Fields inherited from class javax.swing.JComponent | |
TOOL_TIP_TEXT_KEY , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW , accessibleContext , listenerList , ui |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver | |
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH |
Fields inherited from interface javax.swing.SwingConstants | |
BOTTOM , CENTER , EAST , HORIZONTAL , LEADING , LEFT , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , RIGHT , SOUTH , SOUTH_EAST , SOUTH_WEST , TOP , TRAILING , VERTICAL , WEST |
Constructor Summary | |
| |
| |
| |
| |
| |
|
Method Summary | |
void |
|
protected ChangeListener |
|
Hashtable |
|
Hashtable |
|
protected void |
|
AccessibleContext |
|
ChangeListener[] |
|
int |
|
boolean |
|
Dictionary |
|
int |
|
int |
|
int |
|
int |
|
BoundedRangeModel |
|
int |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
SliderUI |
|
String |
|
int |
|
boolean |
|
protected String |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
protected void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected ChangeEvent changeEvent
The ChangeEvent that is passed to all listeners of this slider.
public JSlider()
Creates a new horizontal JSlider object with a minimum of 0, a maximum of 100, and a value of 50.
public JSlider(int orientation)
Creates a new JSlider object with the given orientation and a minimum of 0, a maximum of 100, and a value of 50.
- Parameters:
orientation
- The orientation of the slider (SwingConstants.HORIZONTAL
orSwingConstants.VERTICAL
).
- Throws:
IllegalArgumentException
- iforientation
is not one of the specified values.
public JSlider(int minimum, int maximum)
Creates a new horizontal JSlider object with the given maximum and minimum and a value that is halfway between the minimum and the maximum.
- Parameters:
minimum
- The minimum value of the JSlider.maximum
- The maximum value of the JSlider.
public JSlider(int minimum, int maximum, int value)
Creates a new horizontal JSlider object with the given minimum, maximum, and value.
- Parameters:
minimum
- The minimum value of the JSlider.maximum
- The maximum value of the JSlider.value
- The initial value of the JSlider.
public JSlider(int orientation, int minimum, int maximum, int value)
Creates a new JSlider object with the given orientation, minimum, maximum, and value.
- Parameters:
orientation
- The orientation of the slider (SwingConstants.HORIZONTAL
orSwingConstants.VERTICAL
).minimum
- The minimum value of the JSlider.maximum
- The maximum value of the JSlider.value
- The initial value of the JSlider.
- Throws:
IllegalArgumentException
- iforientation
is not one of the specified values.
public JSlider(BoundedRangeModel model)
Creates a new horizontal JSlider object with the given model.
- Parameters:
model
- The model (null
not permitted).
- Throws:
NullPointerException
- ifmodel
isnull
.
public void addChangeListener(ChangeListener listener)
This method registers a listener to this slider. The listener will be informed of new ChangeEvents.
- Parameters:
listener
- The listener to register.
protected ChangeListener createChangeListener()
Creates a ChangeListener for this Slider.
- Returns:
- A new ChangeListener.
public Hashtable createStandardLabels(int increment)
Creates a hashtable of (Integer, JLabel) pairs that can be used as a label table for this slider. The labels will start from the sliders minimum and increase by the increment. Each label will have a text string indicating their integer value.
- Parameters:
increment
- The increment between labels (must be > 0).
- Returns:
- A hashtable with the labels and their keys.
- Throws:
IllegalArgumentException
- ifincrement
is not greater than zero.
public Hashtable createStandardLabels(int increment, int start)
Creates a hashtable of (Integer, JLabel) pairs that can be used as a label table for this slider. The labels will start from the given start value and increase by the increment. Each label will have a text string indicating its integer value.
- Parameters:
increment
- The increment between labels (must be > 0).start
- The value to start from.
- Returns:
- A hashtable with the labels and their keys.
- Throws:
IllegalArgumentException
- ifincrement
is not greater than zero, orstart
is not within the range of the model.
protected void fireStateChanged()
This method is called whenever the model fires a ChangeEvent. It should propagate the ChangeEvent to its listeners with a new ChangeEvent that identifies the slider as the source.
public AccessibleContext getAccessibleContext()
DOCUMENT ME!
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- DOCUMENT ME!
public ChangeListener[] getChangeListeners()
This method returns an array of all ChangeListeners listening to this slider.
- Returns:
- An array of ChangeListeners listening to this slider.
public int getExtent()
This method returns the extent value for this slider.
- Returns:
- The extent value for this slider.
public boolean getInverted()
This method returns whether the slider is inverted. Horizontal sliders that are not inverted will have the minimums on the left. If they are inverted, the minimums will be on the right. Vertical sliders that are not inverted will have the minimums at the bottom. If they are inverted, the minimums will be at the top.
- Returns:
- Whether this slider is inverted.
public Dictionary getLabelTable()
This method returns the label table for this slider.
- Returns:
- The label table for this slider.
public int getMajorTickSpacing()
This method returns the amount of units between each major tick mark.
- Returns:
- The amount of units between each major tick mark.
public int getMaximum()
This method returns the maximum value of the slider.
- Returns:
- The maximum value of the slider.
public int getMinimum()
This method returns the minimum value of the slider.
- Returns:
- The minimum value of the slider.
public int getMinorTickSpacing()
This method returns the amount of units between each minor tick mark.
- Returns:
- The amount of units between each minor tick mark.
public BoundedRangeModel getModel()
This method returns the model of the slider.
- Returns:
- The slider's model.
public int getOrientation()
This method returns the slider orientation.
- Returns:
- The orientation of the slider.
public boolean getPaintLabels()
This method returns whether labels will be painted.
- Returns:
- Whether labels will be painted.
public boolean getPaintTicks()
This method returns whether the slider will paint its tick marks. In addition to setting this property to true, one of minor tick spacing or major tick spacing must be set to a value greater than 0 in order for ticks to be painted.
- Returns:
- Whether ticks will be painted.
public boolean getPaintTrack()
This method returns whether the track will be painted.
- Returns:
- Whether the track will be painted.
public boolean getSnapToTicks()
This method returns whether this slider is snapping to ticks. Sliders that snap to ticks will automatically move the thumb to the nearest tick mark.
- Returns:
- Whether this slider snaps to ticks.
public SliderUI getUI()
This method returns the slider's UI delegate.
- Returns:
- The slider's UI delegate.
public String getUIClassID()
This method returns a name to identify which look and feel class will be the UI delegate for the slider.
- Overrides:
- getUIClassID in interface JComponent
- Returns:
- The Look and Feel classID. "SliderUI"
public int getValue()
This method returns the current value of the slider.
- Returns:
- The value of the slider stored in the model.
public boolean getValueIsAdjusting()
This method returns this slider's isAdjusting value which is true if the thumb is being dragged.
- Returns:
- The slider's isAdjusting value.
protected String paramString()
This method is used primarily for debugging purposes and returns a string that can be used to represent this slider.
- Overrides:
- paramString in interface JComponent
- Returns:
- A string representing this slider.
public void removeChangeListener(ChangeListener listener)
This method removes a listener from this slider.
- Parameters:
listener
- The listener to remove.
public void setExtent(int extent)
This method sets the extent value for this slider.
- Parameters:
extent
- The extent value for this slider.
public void setInverted(boolean inverted)
This method changes the "inverted" property for this slider.Horizontal sliders that are not inverted will have the minimums on the left. If they are inverted, the minimums will be on the right. Vertical sliders that are not inverted will have the minimums at the bottom. If they are inverted, the minimums will be at the top. However, if the slider's componentOrientation is set to RIGHT_TO_LEFT, then everything gets reversed again.
- Parameters:
inverted
- Whether the slider should be inverted.
public void setLabelTable(Dictionary table)
This method changes the "labelTable" property of this slider.
- Parameters:
table
- The label table for this slider.
public void setMajorTickSpacing(int spacing)
This method changes the "majorTickSpacing" property for this slider. The major tick spacing is the amount of units between each major tick mark.
- Parameters:
spacing
- The amount of units between each major tick mark.
public void setMaximum(int maximum)
This method sets the maximum value of the slider.
- Parameters:
maximum
- The maximum value of the slider.
public void setMinimum(int minimum)
This method sets the minimum value of the slider.
- Parameters:
minimum
- The minimum value of the slider.
public void setMinorTickSpacing(int spacing)
This method changes the "minorTickSpacing" property for this slider. The minor tick spacing is the amount of units between each minor tick mark.
- Parameters:
spacing
- The amount of units between each minor tick mark.
public void setModel(BoundedRangeModel model)
This method changes the "model" property. It also needs to unregister any listeners to the old model and register any listeners to the new model.
- Parameters:
model
- The model to use with the slider.
public void setOrientation(int orientation)
This method changes the "orientation" property of this slider. If the orientation is not VERTICAL or HORIZONTAL, this method does nothing.
- Parameters:
orientation
- The orientation of this slider.
public void setPaintLabels(boolean paint)
This method changes the "paintLabels" property.
- Parameters:
paint
- Whether labels will be painted.
public void setPaintTicks(boolean paint)
This method changes the "paintTicks" property for this slider. In addition to setting this property to true, one of minor tick spacing or major tick spacing must be set to a value greater than 0 in order for ticks to be painted.
- Parameters:
paint
- Whether ticks will be painted.
public void setPaintTrack(boolean paint)
Sets the flag that controls whether or not the track is painted, and sends aPropertyChangeEvent
(for the "paintTrack" property) to all registered listeners.
- Parameters:
paint
- Whether the track will be painted.
public void setSnapToTicks(boolean snap)
This method sets whether this slider will snap to ticks. Sliders that snap to ticks will automatically move the thumb to the nearest tick mark.
- Parameters:
snap
- Whether this slider snaps to ticks.
public void setUI(SliderUI ui)
This method sets the slider's UI delegate.
- Parameters:
ui
- A SliderUI object to use with this slider.
public void setValue(int value)
This method sets the value of the slider.
- Parameters:
value
- The slider's new value.
public void setValueIsAdjusting(boolean adjusting)
This method sets the isAdjusting value for the slider.
- Parameters:
adjusting
- The slider's isAdjusting value.
protected void updateLabelUIs()
This method is called to reset UI delegates for the labels in the labelTable to a default for the current look and feel.
public void updateUI()
This method sets this slider's UI to the UIManager's default for the current look and feel.
- Overrides:
- updateUI in interface JComponent
GNU Classpath (0.20) |