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(String textToCheck)
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, removeValueChangeEventListener
protected 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.d
- Descriptor of corresponding parameter.columns
- Width of text field.public JTextField getJComponent()
ALDSwingComponent
getJComponent
in class ALDSwingComponent
public void setText(String t)
t
- New text to be displayed.public String getText()
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void focusGained(FocusEvent e)
focusGained
in interface FocusListener
public void focusLost(FocusEvent e)
focusLost
in interface FocusListener
protected boolean checkValue(String textToCheck)
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, the
text field is updated if text is provided from somewhere else, and
a ALDSwingValueChangeEvent
is triggered. If the new value is
invalid, a warning is displayed to the user.
textToCheck
- New text to be set in text field.public void disableComponent()
ALDSwingComponent
disableComponent
in class ALDSwingComponent
public void enableComponent()
ALDSwingComponent
enableComponent
in class ALDSwingComponent
public void dispose()
ALDSwingComponent
dispose
in class ALDSwingComponent
Copyright © 2010–2021 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.