John W. Campbell
This class provides a pair of press buttons drawn as an upward pointing arrow
and a downward pointing arrow.
The arrow buttons may also be drawn in a fixed state - either out or in.
Class, fields, constructor and methods:
Class Details
Accessible Fields
Constructor
Class Methods
Resource Methods
Standard Positioning and Sizing
Add/Remove Action Listener
- Package:
- Jdl.JdlView;
- Class name:
- JdlUpDownButton
- Class definition:
- public class JdlUpDownButton
- Extends:
- JPanel
- Implements:
- MouseListener
- Actions:
- When a button is pressed, an action event is posted. The associated object
is the string "up" or "down".
The following accessible fields have been defined:
- public final static int PRESS_BUTTON
- Arrow button mode option: Press buttons.
- public final static int STATIC_OUT
- Arrow button mode option: Static raised buttons.
- public final static int STATIC_IN
- Arrow button mode option: Static inset buttons.
- public final static int STATIC_IN_UP
- Arrow button mode option: Static inset up button.
- public final static int STATIC_IN_DOWN
- Arrow button mode option: Static inset down button.
- public final static int SOLID
- Border type option: Solid.
- public final static int INOUT
- Border type option: Three dimensional (raised/inset).
- public final static int FREE
- Size/Location Constraint: free.
- public final static int DEFAULT_SIZE
- Size Constraint: default (arrow) size (width or height).
- public final static int DEFAULT_ARROW_PAIR_SIZE
- Default arrow pair size.
- static final long serialVersionUID
A single constructor is available.
Constructor:
Default constructor
Constructs an arrow button with the default resources.
- Constructor Definition:
- public JdlUpDownButton()
- Parameters List:
- none
This section has two methods to determine the required size for
the object.
Method:
Find start size - findStartSize
Find start size - findStartSize
Determine the required starting (minimum) size for the JdlUpDownButton
object based on the required arrow size.
- Method Definition:
- public static Dimension findStartSize (int arrow_pair_siz)
- Parameters List:
- arrow_pair_siz
- Arrow pair size in pixels - this is the dimension of a
bounding square.
- Method Return:
-
The calculated size (width, height).
Determine the required starting (minimum) size for the JdlUpDownButton
object based on the default arrow pair size.
- Method Definition:
- public static Dimension findStartSize ()
- Parameters List:
- none
- Method Return:
-
The calculated size (width, height).
This section has methods to set/get the resources associated with the
object determining its appearance and mode of action.
Methods:
Set resize option - setAllowButtonResize
Get resize option - getAllowButtonResize
Set size - setArrowPairSize
Get size - getArrowPairSize
Set border - setArrowBorder
Get border - getArrowBorder
Set border colour - setBorderColor
Set border colour - setBorderColor
Get border colour - getBorderColor
Set border type - setBorderType
Get border type - getBorderType
Set button mode - setButtonMode
Get button mode - getButtonMode
Set 'in' colour - setFillColorIn
Set 'out' colour - setFillColorOut
This method sets the allow button resize resource.
- Method Definition:
- public void setAllowButtonResize(boolean flag)
- Parameters List:
- flag
- If the object is resized and this flag is set to true then the
button will be expanded to fill the largest square which can be fitted into
the new area if this size exceeds the size required by the button resources.
(The default is false for no such resize - instead the button will be centred
in the expanded area).
This method returns the allow button resize resource.
- Method Definition:
- public boolean getAllowButtonResize()
- Parameters List:
- none
- Method Return:
-
Returns the current value of the allow button resize flag.
This method sets the arrow pair size resource (an even number).
- Method Definition:
- public void setArrowPairSize(int siz)
- Parameters List:
- siz
- Arrow pair size in pixels - this is the dimension of a bounding
square. (default = 12, minimum 10, will be rounded up to even if
an odd number given).
This method returns the arrow pair size resource.
- Method Definition:
- public int getArrowPairSize()
- Parameters List:
- none
- Method Return:
-
Returns the arrow pair size resource in pixels.
This method sets the arrows border resource.
- Method Definition:
- public void setArrowBorder(int thickness)
- Parameters List:
- thickness
- This is the required Arrow border thickness in pixels
(default = 2).
This method returns the arrow border resource.
- Method Definition:
- public int getArrowBorder()
- Parameters List:
- none
- Method Return:
-
Returns the arrow border thickness in pixels.
This method sets the border colour resource.
- Method Definition:
- public void setBorderColor (Color colr)
- Parameters List:
- colr
- The border colour - sets this colour for a solid border or
lighter and darker shades of if for a three dimensional button border.
If null (the default), use the background colour if a three dimensional
button or the foreground colour if the button has a solid border.
This method sets the border colour resources.
- Method Definition:
- public void setBorderColor (Color colr, Color brighter, Color darker)
- Parameters List:
- colr
- The border colour - sets the colour for a solid border.
- brighter
- A brighter colour for a three dimensional button border.
- darker
- A darker colour for a three dimensional button border.
This method returns the border colour resource.
- Method Definition:
- public Color getBorderColor()
- Parameters List:
- none
- Method Return:
-
Returns the border colour resource as set.
This method sets the border type resource.
- Method Definition:
- public void setBorderType (int type)
- Parameters List:
- type
- Border type flag:
= 0, solid
= 1, in/out (3-dimensional) (the default)
(May use variables SOLID, INOUT)
This method returns the border type resource.
- Method Definition:
- public int getBorderType()
- Parameters List:
- none
- Method Return:
-
Returns the current border type flag:
= 0, solid
= 1, in/out (3-dimensional)
This method sets the button mode resource.
- Method Definition:
- public void setButtonMode (int mode)
- Parameters List:
- mode
- The button mode flag:
=0 both buttons are press buttons (default)
>0 both are static
=1 both arrows raised
=2 both arrows in
=3 up arrow in
=4 down arrow in
(May use variables PRESS_BUTTON, STATIC_OUT, STATIC_IN, STATIC_IN_UP,
STATIC_IN_DOWN)
This method returns the button mode resource.
- Method Definition:
- public int getButtonMode ()
- Parameters List:
- none
- Method Return:
-
Returns the button mode flag:
=0 both buttons are press buttons (default)
>0 both are static
=1 both arrows raised
=2 both arrows in
=3 up arrow in
=4 down arrow in
This method sets the 'button in' fill colour resources.
- Method Definition:
- public void setFillColorIn (Color colr1, Color colr2)
- Parameters List:
- colr1
- The fill colour when the up button is in the inset (pressed)
state. If null (the default), then the 'button out' fill colour will be used.
- colr2
- The fill colour when the down button is in the inset (pressed)
state. If null (the default), then the 'button out' fill colour will be used.
This method sets the 'button out' fill colour resources.
- Method Definition:
- public void setFillColorOut (Color colr1, Color colr2)
- Parameters List:
- colr1
- The fill colour when the up button is in the raised (unpressed)
state. If null (the default), then the background colour will be used.
- colr2
- The fill colour when the down button is in the raised (unpressed)
state. If null (the default), then the background colour will be used.
This section contains the standard methods for positioning and sizing
the object.
Methods:
Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
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.
This section has methods to add or remove an action listener.
Methods:
Add action listener - addActionListener
Remove action listener - removeActionListener
Get minimum size - getMinimumSize
Get preferred size - getPreferredSize
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 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