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:
ActionListener, FocusListener, EventListener

public class ALDSwingComponentTextField
extends ALDSwingComponent
implements ActionListener, 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  JTextField compTextField
          Associated Swing component.
protected  Class<?> objCl
          Class of objects to be read through this text field.
protected  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(Class<?> cl, int columns)
          Default constructor.
 
Method Summary
 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.
 
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 JTextField compTextField
Associated Swing component.


value

protected String value
Current value of the text field.


objCl

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

Constructor Detail

ALDSwingComponentTextField

public ALDSwingComponentTextField(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

getJComponent

public 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.

setText

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

Parameters:
t - New text to be displayed.

getText

public String getText()
Returns text of text field.

Returns:
Current text in field.

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

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.


disableComponent

public void disableComponent()
Description copied from class: ALDSwingComponent
Method to disable the component, i.e. all graphical elements, to prohibit parameter changes.

Specified by:
disableComponent in class ALDSwingComponent

enableComponent

public void enableComponent()
Description copied from class: ALDSwingComponent
Method to enable the component with all graphical elements again.

Specified by:
enableComponent in class ALDSwingComponent

dispose

public void dispose()
Description copied from class: ALDSwingComponent
Releases all resources, i.e. closes all sub-windows.

Specified by:
dispose in class ALDSwingComponent


Copyright © 2010–2014 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.