John W. Campbell
This class provides a press button drawn as a diamond shape.
The diamond button 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
Overriden Superclass Methods
- Package:
- Jdl.JdlView;
- Class name:
- JdlDiamondButton
- Class definition:
- public class JdlDiamondButton
- Extends:
- JPanel
- Implements:
- MouseListener
- Actions:
- An action event will be generated when the button is pressed. The associated
action command string is "button pressed".
The following accessible fields have been defined:
- public final static int PRESS_BUTTON
- Diamond button mode option: Press button.
- public final static int STATIC_OUT
- Diamond button mode option: Static raised button.
- public final static int STATIC_IN
- Diamond button mode option: Static inset 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 (diamond) size (width or height).
- public final static int DEFAULT_DIAMOND_SIZE
- Default setting for size determining parameter.
- static final long serialVersionUID
A single constructor is available.
Constructor:
Default constructor
Constructs diamond button with default resources.
- Constructor Definition:
- public JdlDiamondButton ()
- Parameters List:
- none
This section has a two methods to determine the required size for
the object.
Methods:
Find start size - findStartSize
Find start size - findStartSize
Determine the required starting (minimum) size for the JdlDiamondButton
object based on the required diamond size.
- Method Definition:
- public static Dimension findStartSize (int diamond_siz)
- Parameters List:
- diamond_siz
- Diamond 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 JdlDiamondButton
object based on the default diamond 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 'allow resize' - setAllowButtonResize
Get 'allow resize' - getAllowButtonResize
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 diamond size - setDiamondSize
Get diamond size - getDiamondSize
Set diamond bevel - setDiamondBevel
Get diamond bevel - getDiamondBevel
Set 'in' fill colour - setFillColorIn
Get 'in' fill colour - getFillColorIn
Set 'out' fill colour - setFillColorOut
Get 'out' fill colour - getFillColorOut
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:
-
Resturns the current value of the allow button resize flag.
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 black 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, button is a press button (default)
= 1, button is a static button in the raised position
= 2, button is a static button in the inset position
(May use variables PRESS_BUTTON, STATIC_OUT, STATIC_IN)
This method returns the button mode resource.
- Method Definition:
- public int getButtonMode ()
- Parameters List:
- none
- Method Return:
-
Returns the button mode flag:
= 0, button is a press button
= 1, button is a static button in the raised position
= 2, button is a static button in the inset position
This method sets the diamond size resource.
- Method Definition:
- public void setDiamondSize(int siz)
- Parameters List:
- siz
- Diamond size in pixels - this is the dimension of a bounding
square. (default = 12)
This method returns the diamond size resource.
- Method Definition:
- public int getDiamondSize()
- Parameters List:
- none
- Method Return:
-
Returns the diamond size resource in pixels.
This method sets the diamond border bevel resource.
- Method Definition:
- public void setDiamondBevel(int thickness)
- Parameters List:
- thickness
- This is the required diamond border bevel thickness
in pixels. (default = 3)
This method returns the diamond border bevel resource.
- Method Definition:
- public int getDiamondBevel()
- Parameters List:
- none
- Method Return:
-
Returns the diamond border bevel thickness in pixels.
This method sets the 'button in' fill colour resource.
- Method Definition:
- public void setFillColorIn (Color colr)
- Parameters List:
- colr
- The fill colour when the button is in the inset (pressed) state.
If null (the default), then the 'button out' fill colour will be used.
This method returns the 'button in' fill colour resource.
- Method Definition:
- public Color getFillColorIn()
- Parameters List:
- none
- Method Return:
-
Returns the current value of the 'button in' fill colour resource.
This method sets the 'button out' fill colour resource.
- Method Definition:
- public void setFillColorOut (Color colr)
- Parameters List:
- colr
- The fill colour when the button is in the raise (unpressed) state.
If null (the default), then the background colour will be used.
This method returns the 'button out' fill colour resource.
- Method Definition:
- public Color getFillColorOut()
- Parameters List:
- none
- Method Return:
-
Returns the current value of the 'button out' fill colour resource.
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
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 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 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