de.unihalle.informatik.Alida.dataio.provider.swing.components
Class ALDSwingComponentTextField

java.lang.Object
  extended by de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
      extended by de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDSwingComponent
          extended by de.unihalle.informatik.Alida.dataio.provider.swing.components.ALDSwingComponentTextField
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.util.EventListener

public class ALDSwingComponentTextField
extends ALDSwingComponent
implements java.awt.event.ActionListener, java.awt.event.FocusListener

Alida-specific Swing component linked to a 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.

Author:
moeller

Field Summary
protected  javax.swing.JTextField compTextField
          Associated Swing component.
protected  java.lang.Class<?> objCl
          Class of objects to be read through this text field.
protected  java.lang.String value
          Current value of the text field.
 
Fields inherited from class de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
listenerList
 
Constructor Summary
ALDSwingComponentTextField(java.lang.Class<?> cl, int columns)
          Default constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
protected  boolean checkValue()
          Method that handles events triggered by the text field.
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 javax.swing.JTextField getJComponent()
          Method to request the provider's GUI element.
 java.lang.String getText()
          Returns text of text field.
 void setText(java.lang.String t)
          Set text of associated text field.
 
Methods inherited from class de.unihalle.informatik.Alida.dataio.provider.swing.events.ALDSwingValueChangeReporter
addValueChangeEventListener, fireALDSwingValueChangeEvent, removeValueChangeEventListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compTextField

protected javax.swing.JTextField compTextField
Associated Swing component.


objCl

protected java.lang.Class<?> objCl
Class of objects to be read through this text field.


value

protected java.lang.String value
Current value of the text field.

Constructor Detail

ALDSwingComponentTextField

public ALDSwingComponentTextField(java.lang.Class<?> cl,
                                  int columns)
Default constructor.

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.

Parameters:
cl - Class of objects to be read via text field.
columns - Width of text field.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

checkValue

protected boolean checkValue()
Method that handles events triggered by the text field.

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.


focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

getJComponent

public javax.swing.JTextField getJComponent()
Description copied from class: ALDSwingComponent
Method to request the provider's GUI element.

Specified by:
getJComponent in class ALDSwingComponent
Returns:
Component to be integrated in a graphical user interface.

getText

public java.lang.String getText()
Returns text of text field.

Returns:
Current text in field.

setText

public void setText(java.lang.String t)
Set text of associated text field.

Parameters:
t - New text to be displayed.