John W. Campbell
This class provides a parameter value object which is used to display a
parameter value which may be changed by the user when required. The
object displays a parameter name (label) at the left hand side and a value
field at the right hand side. When the value field has been selected, a new
value may be input. Pressing the Return or Enter keys completes the
input of the new value. The JdlValue object also allows a drop down menu to be
associated with the parameter value if required or an up/down arrow control.
Special options include on/off or yes/no toggle values and a label only
display.
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:
- JdlValue
- Class definition:
- public class JdlValue
- Extends:
- JPanel
- Implements:
- JdlFramedPanelDrawer
JdlDialogReturns
MouseListener
MouseMotionListener
ActionListener
FocusListener
KeyListener
- Actions:
- When value input is completed an action event is generated. The
action command string is "value_input". Action events
are also posted when value input is first requested (action command string
"replace_started") or if the Escape key is pressed (action command string
"escape"). Changing a toggle value will also generate an action with the
action command string "value_input". The method returnInputString(..) is
used to retrieve the input value.
The following accessible fields have been defined:
- public final static int NO_BUTTON
- Button - no button.
- public final static int MENU_BUTTON
- Button - menu button.
- public final static int UP_DOWN_BUTTON
- Button - up/down button button.
- public final static int RESERVE_SPACE
- Reserve space for button.
- public final static int PREFERRED
- Size Constraint: preferred size.
- public final static int FREE
- Size/Location Constraint: free.
- static final long serialVersionUID
Two constructors are available.
Constructor:
Default constructor
Standard constructor
Construct a JdlValue object with default parameters.
- Constructor Definition:
- public JdlValue()
- Parameters List:
- none
Construct a JdlValue object of requested mimimum dimensions allowing or
disallowing drop-down menu input.
- Constructor Definition:
- public JdlValue(int minw, int minh, int button)
- Parameters List:
- minw
- The minimum width requested (only used if greater than the minimum
needed for the layout.
- minh
- The minimum height requested (only used if greater than the minimum
needed for the layout.
- button
- Allow/disallow a drop down menu or an up/down button for item
value selection:
= 0, no button
= 1, menu button
= 2, up/down button
= 3, reserve space for button
(may use NO_BUTTON, MENU_BUTTON, UP_DOWN_BUTTON, RESERVE_SPACE)
This section contains the main methods used with normal operation
of the object.
Methods:
Set label - setLabelString
Get label - getLabelString
Set menu - setMenuStrings
Get menu - getMenuStrings
Set value - setValueString
Get value - getValueString
Notify error - notifyError
Notify error - notifyError
Notify information - notifyInformation
Cancel current input - cancelInput
Get input string - returnInputString
Is item being input - isItemBeingInput
This method sets the label string.
- Method Definition:
- public void setLabelString(String str)
- Parameters List:
- str
- The required label (parameter name) string (default = null).
This method returns the label string.
- Method Definition:
- public String getLabelString()
- Parameters List:
- none
- Method Return:
-
Returns the label string.
This method sets the menu strings.
strs An array of strings for a drop down menu of valid values (default = null
for no such menu). To be used, the menu allowed flag must also be set to
true (see setMenuAllowed(..) method).
- Method Definition:
- public void setMenuStrings(String[] strs)
- Parameters List:
- strs
- An array of the required menu strings.
Get the menu strings.
- Method Definition:
- public String[] getMenuStrings()
- Parameters List:
- none
- Method Return:
-
Returns an array of menu strings (A reference not a copy).
This method sets the value string.
- Method Definition:
- public void setValueString (String str)
- Parameters List:
- str
- The parameter value string (default = null).
Get the value string.
- Method Definition:
- public String getValueString()
- Parameters List:
- none
- Method Return:
-
Returns the parameter value string (A reference not a copy).
This method notifies an error condition with a dialogue.
If an invalid parameter value is detected, then the program may use this
method to handle the error condition. An error dialogue box will be
displayed containing the user defined error message string and a message
indicating that the old value will be replaced when the CONTINUE button
within the dialogue box is selected.
- Method Definition:
- public void notifyError(String str)
- Parameters List:
- str
- An error string for the error dialogue box.
This method notifies an error condition (silently).
If an invalid parameter value is detected, then the program may use this
method to handle the error condition. The old value will be replaced.
- Method Definition:
- public void notifyError()
- Parameters List:
- none
This method outputs an information dialogue to tell the user for example
about further consequences of the parameter update. The dialogue
box has a single 'OK' button.
- Method Definition:
- public void notifyInformation(String str)
- Parameters List:
- str
- An error string for the error dialogue box.
This method cancels the current input (if any) & replaces the value with
the previous value string.
- Method Definition:
- public void cancelInput()
- Parameters List:
- none
This method returns the last input string.
- Method Definition:
- public String returnInputString()
- Parameters List:
- none
- Method Return:
-
Returns the last parameter value string which has been input via the
value field.
This method may be called to determine whether or not an item is currently
being input.
- Method Definition:
- public boolean isItemBeingInput()
- Parameters List:
- none
- Method Return:
-
true if item being input, otherwise false.
This section has methods to set/get the resources associated with the
object determining its appearance and mode of action.
Methods:
Set arrow separator - setArrowSeparator
Get arrow separator - getArrowSeparator
Set cursor colour - setCursorColor
Get cursor colour - getCursorColor
Set cursor type - setCursorType
Get cursor type - getCursorType
Set horizontal expand - setExpandValueHorizontal
Get horizontal expand - getExpandValueHorizontal
Set vertical expand - setExpandValueVertical
Get vertical expand - getExpandValueVertical
Set label alignment - setLabelAlignment
Get label alignment - getLabelAlignment
Set label font - setLabelFont
Get label font - getLabelFont
Set bold label font - setLabelBoldFont
Get bold label font - getLabelBoldFont
Stored value characters - setMaximumValueCharacters
Get stored value characters - getMaximumValueCharacters
Set menu allowed - setMenuAllowed
Get menu allowed - getMenuAllowed
Set menu only - setMenuOnly
Get menu only - getMenuOnly
Set label size - setFixedLabelTextSize
Get label size - getFixedLabelTextSize
Set up/down handling - setUpDownHandling
Set up/down handler - setUpDownHandling
Set integer increment - setUpDownHandling
Set double increment - setUpDownHandling
Get up/down allowed - getUpDownAllowed
Displayed value characters - setNumberValueDisplayedCharacters
Get displayed value characters - getNumberValueDisplayedCharacters
Set surround height - setSurroundHeight
Get surround height - getSurroundHeight
Set surround width - setSurroundWidth
Get surround width - getSurroundWidth
Set value font - setValueFont
Get value font - getValueFont
Set value freeze - setValueFreeze
Get value freeze - getValueFreeze
Set value separator - setValueSeparator
Get value separator - getValueSeparator
Set shadow thickness - setValueShadowThickness
Get shadow thickness - getValueShadowThickness
Set value type - setValueType
Get value type - getValueType
Set variable label - setVariableLabelSize
Get variable label - getVariableLabelSize
This method sets the arrow separator resource.
- Method Definition:
- public void setArrowSeparator(int sep)
- Parameters List:
- sep
- The minimum separation width between the value field and the
arrow button (if present) which indicates the presence of a drop down menu
(default = 2).
This method returns the arrow separator resource.
- Method Definition:
- public int getArrowSeparator()
- Parameters List:
- none
- Method Return:
-
Returns the value of thr arrow separator resource.
This method sets the cursor colour resource.
- Method Definition:
- public void setCursorColor(Color colr)
- Parameters List:
- colr
- The required cursor colout.
This method returns the cursor colour resource.
- Method Definition:
- public Color getCursorColor()
- Parameters List:
- none
- Method Return:
-
Returns the current cursor colour.
This method sets the cursor type resource.
- Method Definition:
- public void setCursorType(int type)
- Parameters List:
- type
- The required cursor type:
= 0, a horizontal cursor at the foot of the new character position
(the default)
= 1, a vertical line at the left hand side of the new character
position
= 2, a solid block of colour covering the new character position
This method returns the cursor type resource.
- Method Definition:
- public int getCursorType()
- Parameters List:
- none
- Method Return:
-
Returns the cursor type flag.
This method sets the expand value horizontally resource.
- Method Definition:
- public void setExpandValueHorizontal(boolean e)
- Parameters List:
- e
- Allow or do not allow (the default) the value area to be expanded
horizontally if the JdlValue object is resized.
This method returns the expand value horizontally resource.
- Method Definition:
- public boolean getExpandValueHorizontal()
- Parameters List:
- none
- Method Return:
-
Returns the value of the flag.
This method sets the expand value vertically resource.
- Method Definition:
- public void setExpandValueVertical(boolean e)
- Parameters List:
- e
- Allow or do not allow (the default) the value area to be expanded
vertically if the JdlValue object is resized.
This method returns the expand value vertically resource.
- Method Definition:
- public boolean getExpandValueVertical()
- Parameters List:
- none
- Method Return:
-
Returns the value of the flag.
This method sets the label alignment resource.
- Method Definition:
- public void setLabelAlignment(int align)
- Parameters List:
- align
- The label alignment within the parameter name (label) field, =0
center the label in the field, =1 align to the left of the field (the
default), =2 align to the right of the field.
This method returns the label alignment resource.
- Method Definition:
- public int getLabelAlignment()
- Parameters List:
- none
- Method Return:
-
Returns the label alignment flag.
This method sets the label font resource.
- Method Definition:
- public void setLabelFont (Font font)
- Parameters List:
- font
- The required font for the label (parameter name) (Default = null
for default AWT label font).
This method returns the label font resource.
- Method Definition:
- public Font getLabelFont()
- Parameters List:
- none
- Method Return:
-
Returns the current label font.
This method sets the label bold font resource.
- Method Definition:
- public void setLabelBoldFont (Font font)
- Parameters List:
- font
- Used in dialog error messages.
This method returns the label bold font resource.
- Method Definition:
- public Font getLabelBoldFont()
- Parameters List:
- none
- Method Return:
-
Returns the current label bold font.
This method sets the maximum number of stored value characters resource.
- Method Definition:
- public void setMaximumValueCharacters(int n)
- Parameters List:
- n
- The maximum no. of characters allowed in the value string (default
= 50).
This method sets the maximum value characters resource.
- Method Definition:
- public int getMaximumValueCharacters()
- Parameters List:
- none
- Method Return:
-
Returns the maximum no. of characters allowed in the value string.
This method sets the menu allowed resource.
- Method Definition:
- public void setMenuAllowed(boolean men)
- Parameters List:
- men
- This indicates whether or not the value field may have a drop
down menu associated with it. If true, the space will be allocated for the
arrow button for the menu though the arrow button will not be displayed
unless a menu has been defined by setting the menuStrings resource (see
setMenuStrings method). (default = false). Cannot be turned on if up/down
button is currently allowed.
This method returns the menu allowed resource.
- Method Definition:
- public boolean getMenuAllowed()
- Parameters List:
- none
- Method Return:
-
Returns the value of the menu allowed flag.
This method sets a flag which gives the option of allowing the input of
a new value using only the menu. It only takes effect when a menu is
defined for the value item.
- Method Definition:
- public void setMenuOnly(boolean only)
- Parameters List:
- only
- If true set the 'input from menu only' option, if false
disable this option and allow normal input via the value area.
This method returns the value of the 'input from menu only' option.
- Method Definition:
- public boolean getMenuOnly()
- Parameters List:
- none
- Method Return:
-
The 'input from menu only' flag.
This method sets the label fixed label text size resource. The variable
label size resource is automatically set to false by this method
(see setVariableLabelSize(..)) and must remain so for this size to be used.
- Method Definition:
- public void setFixedLabelTextSize(int w, int h)
- Parameters List:
- w
- The required label text width in pixels.
- h
- The required label text height in pixels.
This method returns the label fixed label text size resource.
- Method Definition:
- public Dimension getFixedLabelTextSize()
- Parameters List:
- none
- Method Return:
-
Returns fixed label text size resource.
This method sets the up/down button handling options. This version will
post an action event (command "up" or "down") when the respective button
is pressed.
- Method Definition:
- public void setUpDownHandling(boolean but)
- Parameters List:
- but
- If true, an up/down button will be displayed; if false any existing
up/down button will be removed. Cannot be turned on if the menu allowed
button is currently enabled.
This method sets the up/down button handling options. This version will
use the user defined handler to change the value as required.
- Method Definition:
- public void setUpDownHandling(JdlValueUpDownHandler handler)
- Parameters List:
- none
This method sets the up/down button handling options. This version sets
an internal option to increment/decrement an integer value.
- Method Definition:
- public void setUpDownHandling(int incr)
- Parameters List:
- none
This method sets the up/down button handling options. This version sets
an internal option to increment/decrement a floating point value.
- Method Definition:
- public void setUpDownHandling(double fp)
- Parameters List:
- none
This method returns the up/down button allowed resource.
- Method Definition:
- public boolean getUpDownAllowed()
- Parameters List:
- none
- Method Return:
-
Returns the value of the up/down button allowed flag.
This method sets the number of displayed value characters resource.
- Method Definition:
- public void setNumberValueDisplayedCharacters (int n)
- Parameters List:
- n
- The number of parameter value characters to be displayed
i.e. the width of the parameter value field. The number of characters
which may be stored for the parameter value may exceed this if required (see
the maximum value characters resource). If the current parameter value string
exceeds the displayed length available then a scrolling mechanism is invoked.
This method returns the number of displayed value characters resource.
- Method Definition:
- public int getNumberValueDisplayedCharacters()
- Parameters List:
- none
- Method Return:
-
Returns the requested number of displayed value characters.
This method sets the surround height resource.
- Method Definition:
- public void setSurroundHeight(int minh)
- Parameters List:
- minh
- Surround border height (top & bottom) added to the minimum
requirements for the label, value area etc.
This method returns the surround height resource.
- Method Definition:
- public int getSurroundHeight()
- Parameters List:
- none
- Method Return:
-
Returns the surround height.
This method sets the surround width resource.
- Method Definition:
- public void setSurroundWidth(int minw)
- Parameters List:
- minw
- Surround border width (left and right) added to the minimum
requirements for the label, value area etc.
This method returns the surround width resource.
- Method Definition:
- public int getSurroundWidth()
- Parameters List:
- none
- Method Return:
-
Returns the surround width.
This method sets the value font resource.
- Method Definition:
- public void setValueFont(Font font)
- Parameters List:
- font
- The font for the parameter value string (default = null, uses
label font). Note: should normally be a fixed width font.
This method returns the value font resource.
- Method Definition:
- public Font getValueFont()
- Parameters List:
- none
- Method Return:
-
Returns the font for the parameter value string.
This method sets the value freeze resource.
- Method Definition:
- public void setValueFreeze(boolean frz)
- Parameters List:
- frz
- Flag to freeze (disable) the input of a new value. The input is
frozen if the flag is true and the normal value input mode operates if the
flag is false (the default).
This method returns the value freeze resource.
- Method Definition:
- public boolean getValueFreeze()
- Parameters List:
- none
- Method Return:
-
Returns the value of the 'value freeze' flag.
This method sets the value separator resource.
- Method Definition:
- public void setValueSeparator(int sep)
- Parameters List:
- sep
- The separation required between the parameter label and the
parameter value fields (default = 2).
This method returns the value separator resource.
- Method Definition:
- public int getValueSeparator()
- Parameters List:
- none
- Method Return:
-
Returns the value separator width.
This method sets the value shadow thickness resource.
- Method Definition:
- public void setValueShadowThickness(int th)
- Parameters List:
- th
- Shadow thickness for value area surround frame (default = 2).
This method returns the value shadow thickness resource.
- Method Definition:
- public int getValueShadowThickness()
- Parameters List:
- none
- Method Return:
-
Returns the value shadow thickness.
This method sets the value type resource.
- Method Definition:
- public void setValueType(int type)
- Parameters List:
- type
- The value type flag:
= 0, normal
= 1, on/off toggle on value
= 2, on/off toggle off value
= 3, yes/no toggle yes value
= 4, yes/no toggle no value
= 5, label only
This method returns the value type resource.
- Method Definition:
- public int getValueType()
- Parameters List:
- none
- Method Return:
-
Returns the value type flag.
This method sets the variable label size resource.
- Method Definition:
- public void setVariableLabelSize(boolean var)
- Parameters List:
- var
- Allow or disallow a variable label size using actual label
text to get the size for the label field rather than using a pre-calculated
size input by the user (see setFixedLabelTextSize) (default = false).
This method returns the variable label size resource.
- Method Definition:
- public boolean getVariableLabelSize()
- Parameters List:
- none
- Method Return:
-
Returns the value of the variable label size flag.
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