public class Slider extends Component implements MouseListener, MouseMotionListener
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
GRIP_BOTTOM_Y
Y-coordinate of bottom of grip.
|
static int |
GRIP_HEIGHT
Height of grip.
|
static int |
GRIP_TOP_Y
Y-coordinate of top of grip.
|
static int |
GRIP_WIDTH
Width of grip.
|
static int |
LINE_LEVEL
Y-coordinate of slider line.
|
protected float |
maximum
Maximum value of slider.
|
protected Dimension |
maxSize
Maximum widget size.
|
protected float |
minimum
Minimum value of slider.
|
protected Dimension |
minSize
Minimum widget size.
|
protected Dimension |
prefSize
Preferred widget size.
|
static int |
SLIDER_PREF_HEIGHT
Preferred slider height.
|
static int |
SLIDER_PREF_WIDTH
Preferred slider width.
|
protected float |
value
Current value of slider.
|
protected int |
width
Current width of slider.
|
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
Slider()
Constructs a slider with default value, minimum and maximum.
|
Slider(float value,
float min,
float max)
Constructs a slider with the specified value, minimum and maximum.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Adds a listener to be notified of slider changes.
|
float |
getMaximum()
Gets maximum slider value.
|
Dimension |
getMaximumSize()
Returns maximum size oa slider.
|
float |
getMinimum()
Gets minimum slider value.
|
Dimension |
getMinimumSize()
Returns minimum size of slider.
|
Dimension |
getPreferredSize()
Returns preferred size of slider.
|
float |
getValue()
Gets current slider value.
|
static void |
main(String[] argv)
Main method for testing purposes.
|
void |
mouseClicked(MouseEvent e)
Not used.
|
void |
mouseDragged(MouseEvent e)
MouseMotionListener method for moving grip.
|
void |
mouseEntered(MouseEvent e)
Not used.
|
void |
mouseExited(MouseEvent e)
Not used.
|
void |
mouseMoved(MouseEvent e)
Not used.
|
void |
mousePressed(MouseEvent e)
MouseListener method for moving grip.
|
void |
mouseReleased(MouseEvent e)
MouseListener method for moving grip.
|
void |
notifyListeners()
Notifies listeners of slider change.
|
void |
paint(Graphics g)
Draws the slider.
|
void |
removeActionListener(ActionListener l)
Removes a listener to be notified of slider changes.
|
void |
repaint() |
void |
setActionCommand(String cmd)
Sets command string for slider change notification.
|
void |
setBounds(float min,
float max)
Sets minimum and maximum slider values.
|
void |
setBounds(int x,
int y,
int w,
int h)
Detects changes in slider width.
|
void |
setMaximumSize(Dimension dim)
Sets preferred size of slider.
|
void |
setMinimumSize(Dimension dim)
Sets minimum size of slider.
|
void |
setPreferredSize(Dimension dim)
Sets preferred size of slider.
|
void |
setValue(float value)
Sets current slider value.
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
public static final int SLIDER_PREF_HEIGHT
public static final int SLIDER_PREF_WIDTH
public static final int GRIP_WIDTH
public static final int GRIP_HEIGHT
public static final int GRIP_TOP_Y
public static final int GRIP_BOTTOM_Y
public static final int LINE_LEVEL
protected int width
protected float value
protected float minimum
protected float maximum
protected Dimension minSize
protected Dimension prefSize
protected Dimension maxSize
public Slider()
public Slider(float value, float min, float max)
public float getValue()
public float getMinimum()
public float getMaximum()
public void setValue(float value)
public void setBounds(float min, float max)
public void setBounds(int x, int y, int w, int h)
public void addActionListener(ActionListener l)
public void removeActionListener(ActionListener l)
public void setActionCommand(String cmd)
public void notifyListeners()
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
public Dimension getMinimumSize()
getMinimumSize
in class Component
public void setMinimumSize(Dimension dim)
setMinimumSize
in class Component
public Dimension getPreferredSize()
getPreferredSize
in class Component
public void setPreferredSize(Dimension dim)
setPreferredSize
in class Component
public Dimension getMaximumSize()
getMaximumSize
in class Component
public void setMaximumSize(Dimension dim)
setMaximumSize
in class Component
public static void main(String[] argv)
Copyright © 1996–2023 The SSEC Visualization Project. All rights reserved.