3.10.8 - Up/Down Button - JdlUpDownButton

John W. Campbell

3.10.8.1 Introduction

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

3.10.8.2 Class Details

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".

3.10.8.3 Accessible Fields

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

3.10.8.4 Constructor

3.10.8.4.1 Introduction

A single constructor is available.

Constructor:

Default constructor

3.10.8.4.2 Default constructor

Constructs an arrow button with the default resources.

Constructor Definition:
public JdlUpDownButton()
Parameters List:
none

3.10.8.5 Class Methods

3.10.8.5.1 Introduction

This section has two methods to determine the required size for the object.

Method:

Find start size - findStartSize
Find start size - findStartSize

3.10.8.5.2 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).

3.10.8.5.3 Find start size - findStartSize

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).

3.10.8.6 Resource Methods

3.10.8.6.1 Introduction

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

3.10.8.6.2 Set resize option - setAllowButtonResize

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).

3.10.8.6.3 Get resize option - getAllowButtonResize

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.

3.10.8.6.4 Set size - setArrowPairSize

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).

3.10.8.6.5 Get size - getArrowPairSize

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.

3.10.8.6.6 Set border - setArrowBorder

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).

3.10.8.6.7 Get border - getArrowBorder

This method returns the arrow border resource.

Method Definition:
public int getArrowBorder()
Parameters List:
none
Method Return:
Returns the arrow border thickness in pixels.

3.10.8.6.8 Set border colour - setBorderColor

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.

3.10.8.6.9 Set border colour - setBorderColor

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.

3.10.8.6.10 Get border colour - getBorderColor

This method returns the border colour resource.

Method Definition:
public Color getBorderColor()
Parameters List:
none
Method Return:
Returns the border colour resource as set.

3.10.8.6.11 Set border type - setBorderType

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)

3.10.8.6.12 Get border type - getBorderType

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)

3.10.8.6.13 Set button mode - setButtonMode

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)

3.10.8.6.14 Get button mode - getButtonMode

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

3.10.8.6.15 Set 'in' colour - setFillColorIn

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.

3.10.8.6.16 Set 'out' colour - setFillColorOut

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.

3.10.8.7 Standard Positioning and Sizing

3.10.8.7.1 Introduction

This section contains the standard methods for positioning and sizing the object.

Methods:

Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints

3.10.8.7.2 Set position constraints - setLocationConstraints

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.

3.10.8.7.3 Set size constraints - setSizeConstraints

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.

3.10.8.8 Add/Remove Action Listener

3.10.8.8.1 Introduction

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

3.10.8.8.2 Add action listener - addActionListener

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.

3.10.8.8.3 Remove action listener - removeActionListener

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.

3.10.8.8.4 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

Method Definition:
public Dimension getMinimumSize()
Parameters List:
none

3.10.8.8.5 Get preferred size - getPreferredSize

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