John W. Campbell
This class provides a horizontal slider object.
Class, fields, constructor and methods:
Class Details
Accessible Fields
Constructor
Operational Methods
Resource Methods
Standard Positioning and Sizing
Add/Remove Action Listener
Overriden Superclass Methods
- Package:
- Jdl.JdlView;
- Class name:
- JdlSlider
- Class definition:
- public class JdlSlider
- Extends:
- JdlFramedPanel
- Implements:
- MouseListener
MouseMotionListener
- Actions:
- An action event will be generated when the slider has been moved and the
mouse button released. If required action events may also be generated which
track the slider movement continuously. The associated object is the string
"slider input" in the former case and "slider motion" in the latter case.
The following accessible fields have been defined:
- public final static int PREFERRED
- Size Constraint: preferred size.
- public final static int FREE
- Size/Location Constraint: free.
- static final long serialVersionUID
- JdlFramedPanel grip
- Color grip_bg_colr
A single constructor is available.
Constructor:
Default constructor
Constructs a slider with the default resources.
- Constructor Definition:
- public JdlSlider()
- Parameters List:
- none
This section contains the main methods used with normal operation
of the object.
Methods:
Set travel length - setTravelLength
Set values - setSliderValues
Set value - setValue
Get value - getSliderValue
This method sets the travel length.
- Method Definition:
- public void setTravelLength (int tlen)
- Parameters List:
- tlen
- The travel length of the slider. The slider travels from 0 to
'tlen' i.e. there will be 'tlen+1' distinct slider positions possible.
This method sets slider values resources.
- Method Definition:
- public void setSliderValues (int min, int max, int val)
- Parameters List:
- min
- The minimum value for the slider range (default = 0).
- max
- The maximum value for the slider range (default = 100) - must
be greater than 'min'.
- val
- The currently required slider value (default = 50) - must be within
the range 'min' to 'max'. The slider value resource changes as the slider is
moved. This method sets the three resources to ensure consistency. Separate
methods return each of the three values.
This method sets the slider value.
- Method Definition:
- public void setValue (int val)
- Parameters List:
- val
- The required slider value. This must be in the range 0 to 100
or the range 'min' to 'max' as set by the setSliderValues(..) method.
This method returns the current slider value.
- Method Definition:
- public int getSliderValue()
- Parameters List:
- none
- Method Return:
-
Returns the current slider value.
This section has methods to set/get the resources associated with the
object determining its appearance and mode of action.
Methods:
Set monitor mode - setContinuousMonitor
Get monitor mode - getContinuousMonitor
Set grip border - setGripBorder
Get grip border - getGripBorder
Set grip height - setGripHeight
Get grip height - getGripHeight
Set grip width - setGripWidth
Get grip width - getGripWidth
Get maximum value - getSliderMaximum
Get minimum value - getSliderMinimum
This method sets the continuous monitor resource.
- Method Definition:
- public void setContinuousMonitor(boolean flag)
- Parameters List:
- flag
- Set to true for continuous monitoring of slider value (via
action events) as the slider grip is dragged (default = false).
This method returns the continuous monitor resource.
- Method Definition:
- public boolean getContinuousMonitor()
- Parameters List:
- none
- Method Return:
-
Returns the current value of the continuous monitor resource flag.
This method sets the grip border resource.
- Method Definition:
- public void setGripBorder(int width)
- Parameters List:
- width
- The width of the slider grip border in pixels (default = 2,
minimum = 2).
This method returns the grip border resource.
- Method Definition:
- public int getGripBorder()
- Parameters List:
- none
- Method Return:
-
Returns the slider grip border width in pixels.
This method sets the grip height resource.
- Method Definition:
- public void setGripHeight(int height)
- Parameters List:
- height
- The height of the slider grip in pixels (default = 16).
This method returns the grip height resource.
- Method Definition:
- public int getGripHeight()
- Parameters List:
- none
- Method Return:
-
Returns the slider grip height in pixels.
This method sets the grip width resource.
- Method Definition:
- public void setGripWidth(int width)
- Parameters List:
- width
- The width of the slider grip in pixels (default = 12, minimum
= 10).
This method returns the grip width resource.
- Method Definition:
- public int getGripWidth()
- Parameters List:
- none
- Method Return:
-
Returns the slider grip width in pixels.
This method returns the slider maximum value resource.
- Method Definition:
- public int getSliderMaximum()
- Parameters List:
- none
- Method Return:
-
Returns the slider maximum value resource (note - set via
setSliderValues)
This method returns the slider minimum value resource.
- Method Definition:
- public int getSliderMinimum()
- Parameters List:
- none
- Method Return:
-
Returns the slider minimum value resource (note - set via
setSliderValues)
This section contains the standard methods for positioning and sizing
the object.
Methods:
Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
Set minimum height - setMinimumHeight
Set minimum width - setMinimumWidth
Set constraints on the Jdl object positioning.
- Method Definition:
- public void setLocationConstraints (int constraint_x, int constraint_y)
- Parameters List:
- constraint_x
- Constrain the Jdl Object 'x' position = the required
Jdl Object 'x' position (overrides setLocation method) or FREE if the 'x'
position may be set by the setLocation method and hence possibly by the
layout manager.
- constraint_y
- Constrain the Jdl Object 'y' position = the required
the Jdl Object 'y'position (overrides setLocation method) or FREE if the 'y'
position may be set by the setLocation method and hence possibly by the
layout manager.
Set constraints on the Jdl Object resizing permitted.
- Method Definition:
- public void setSizeConstraints (int constraint_w, int constraint_h)
- Parameters List:
- constraint_w
- Constrain the Jdl Object width = the required
Jdl Object width, or PREFERRED (default) if the width is to be calculated
from the current resources, or FREE if the width may be resized to anything
greater than the minimum width required.
- constraint_h
- Constrain the Jdl Object height = the required
Jdl Object height, or PREFERRED (default) if the height is to be calculated
from the current resources, or FREE if the height may be resized to anything
greater than the minimum height required.
Set the minimum height resource.
- Method Definition:
- public void setMinimumHeight(int minh)
- Parameters List:
- minh
- The minimum height required for the object (ignored if less
than that required by the minimum layout) (default = 0).
Set the minimum width resource.
- Method Definition:
- public void setMinimumWidth(int minw)
- Parameters List:
- minh
- The minimum width required for the object (ignored if less
than that required by the minimum layout) (default = 0).
This section has methods to add or remove an action listener.
Methods:
Add action listener - addActionListener
Remove action listener - removeActionListener
This adds the specified action listener to receive action events from this
object.
- Method Definition:
- public void addActionListener(ActionListener listener)
- Parameters List:
- listener
- The action listener to be added.
This removes the specified action listener so that it no longer receives action
events from this object.
- Method Definition:
- public void removeActionListener(ActionListener listener)
- Parameters List:
- listener
- The action listener to be removed.
This section contains methods which override the corresponding superclass
methods. These are basically standard for JdlView objects and comprise
methods to set background and foreground colours and to get the minimum
and preferred sizes for the object. (The paintComponent method is also
over-ridden but is not normally called by the user).
Methods:
Set background - setBackground
Set background colours - setBackground
Set foreground - setForeground
Get minimum size - getMinimumSize
Get preferred size - getPreferredSize
This method sets the background colour resource.
- Method Definition:
- public void setBackground (Color c)
- Parameters List:
- c
- The color to become this object's background color.
This method sets the background colour resource and brighter and darker shades
of that colour (e.g. for 3-D frames).
- Method Definition:
- public void setBackground (Color c, Color brighter, Color darker)
- Parameters List:
- c
- The background colour.
- brighter
- A brighter shade of the background colour.
- darker
- A darker shade of the background colour.
This method sets the foreground colour resource.
- Method Definition:
- public void setForeground (Color c)
- Parameters List:
- c
- The color to become this object's foreground color.
This method returns the minimum size of the component.
- Method Definition:
- public Dimension getMinimumSize()
- Parameters List:
- none
This method returns the preferred size of the component.
- Method Definition:
- public Dimension getPreferredSize()
- Parameters List:
- none
⇑ Up 3
⇑ Up 2
⇑ Up 1
⇑ Top of this