Package PamView.dialog.smart
Class ImmediateTextField<T>
java.lang.Object
PamView.dialog.smart.ImmediateTextField<T>
Text field which can immediately respond to text being entered and
update a corresponding value in a PAMGurd control structure. Will call abstract
function valueChange whenever the control is typed in, enter is hit or the focus
of the control is lost. Concrete implementations can then update parameters
accordingly.
Should be able to handle Double, Integer and String types. To add others, just need to add more options to the getValue() function.
- Author:
- Doug Gillespie.
-
Constructor Summary
ConstructorDescriptionImmediateTextField
(Class<T> fieldClass, int fieldLength, String prefix, String suffix, boolean colourManaged) Construct text field that calls back whenever the value is changed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToParent
(JComponent parent, GridBagConstraints c) Add the components to the parent component.void
setNumberFormat
(NumberFormat numberFormat) void
void
void
setToolTipText
(String tip, boolean preandpost) void
abstract void
valueChange
(T newValue, boolean valueError, boolean lostFocus) Called whenever the value changes and also when the keyboard focus leaves the control.
-
Constructor Details
-
ImmediateTextField
public ImmediateTextField(Class<T> fieldClass, int fieldLength, String prefix, String suffix, boolean colourManaged) Construct text field that calls back whenever the value is changed.- Parameters:
fieldClass
- data class (Double, Integer or String) must match the template classfieldLength
- field length (characters)prefix
- optional text prefix to displaysuffix
- optional text suffix to displaycolourManaged
- Manage day / night colours using standard themes.
-
-
Method Details
-
setValue
-
setToolTipText
-
getPrefix
- Returns:
- the prefix
-
setPrefix
- Parameters:
prefix
- the prefix to set
-
getSuffix
- Returns:
- the suffix
-
setSuffix
- Parameters:
suffix
- the suffix to set
-
getNumberFormat
- Returns:
- the numberFormat
-
setNumberFormat
- Parameters:
numberFormat
- the numberFormat to set
-
getTextField
- Returns:
- the textField
-
getPreLabel
- Returns:
- the preLabel
-
getPostLabel
- Returns:
- the postLabel
-
valueChange
Called whenever the value changes and also when the keyboard focus leaves the control. Some users may want to respond to every key stroke, others only when the keyboard focus leaves the control.- Parameters:
newValue
- value in text field. Will be null if valueErrorvalueError
- error in value, e.g. if number is invalidlostFocus
- focus has moved from the control or enter has been pressed.
-
addToParent
Add the components to the parent component. By default, components will be laid out with an increment of the x value in the gridbag constraints of one per non null component. If you require different bahaviour, get the components individually and do as you like.- Parameters:
parent
- Parent componentc
- gridbag constraints with correct start position for first non null component.
-