public class ALDSwingComponentTextField extends ALDSwingComponent implements ActionListener, FocusListener
JTextField.
This component reports events on changes of the text entry. In addition it features a value checking. It verifies if the current text entry can be converted to an object of the class initially specified on contruction of the object. If not, a warning message is displayed.
Important note for programmers using this component:
this checking mechanism does only properly work if the text in the
component is never changed directly. Changes should exclusively be done by
using the setText(String t) method of this class.
| Modifier and Type | Field and Description |
|---|---|
protected JTextField |
compTextField
Associated Swing component.
|
protected Class<?> |
objCl
Class of objects to be read through this text field.
|
protected ALDParameterDescriptor |
paramDescriptor
Descriptor of associated (operator) parameter.
|
protected String |
value
Current value of the text field.
|
listenerList| Constructor and Description |
|---|
ALDSwingComponentTextField(Class<?> cl,
ALDParameterDescriptor d,
int columns)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(ActionEvent e) |
protected boolean |
checkValue()
Method that handles events triggered by the text field.
|
void |
disableComponent()
Method to disable the component, i.e. all graphical elements, to
prohibit parameter changes.
|
void |
dispose()
Releases all resources, i.e. closes all sub-windows.
|
void |
enableComponent()
Method to enable the component with all graphical elements again.
|
void |
focusGained(FocusEvent e) |
void |
focusLost(FocusEvent e) |
JTextField |
getJComponent()
Method to request the provider's GUI element.
|
String |
getText()
Returns text of text field.
|
void |
setText(String t)
Set text of associated text field.
|
addValueChangeEventListener, fireALDSwingValueChangeEvent, removeValueChangeEventListenerprotected JTextField compTextField
protected String value
protected Class<?> objCl
protected ALDParameterDescriptor paramDescriptor
public ALDSwingComponentTextField(Class<?> cl, ALDParameterDescriptor d, int columns)
The class parameter allows to specify a class which is used to check the validity of text field entries. If the class parameter is null, validation is disabled.
cl - Class of objects to be read via text field.columns - Width of text field.public JTextField getJComponent()
ALDSwingComponentgetJComponent in class ALDSwingComponentpublic void setText(String t)
t - New text to be displayed.public String getText()
public void actionPerformed(ActionEvent e)
actionPerformed in interface ActionListenerpublic void focusGained(FocusEvent e)
focusGained in interface FocusListenerpublic void focusLost(FocusEvent e)
focusLost in interface FocusListenerprotected boolean checkValue()
The method at first checks if the value of the text field has changed.
If so, it subsequently validates if the new value is valid with regard
to the class linked to this GUI element. If both checks are passed
a ALDSwingValueChangeEvent is triggered. If the new value is
invalid, a warning is displayed to the user.
public void disableComponent()
ALDSwingComponentdisableComponent in class ALDSwingComponentpublic void enableComponent()
ALDSwingComponentenableComponent in class ALDSwingComponentpublic void dispose()
ALDSwingComponentdispose in class ALDSwingComponentCopyright © 2010–2015 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.