lisken.uitoolbox
Class JTextComponentFocusSelector

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by lisken.uitoolbox.JTextComponentFocusSelector
All Implemented Interfaces:
java.awt.event.FocusListener, java.awt.event.MouseListener, java.util.EventListener

public class JTextComponentFocusSelector
extends java.awt.event.MouseAdapter
implements java.awt.event.FocusListener

Implementation of FocusListener and MouseListener, that can be used to manage the automatic selection of the text in a JTextComponent when it gains focus. This listener should not directly be added as a listener to a text field, but the method setField(javax.swing.text.JTextComponent) should be used.


Constructor Summary
JTextComponentFocusSelector(javax.swing.text.JTextComponent tc)
          Creates a new JTextComponentFocusSelector and adds it as a listener to tc.
 
Method Summary
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void setField(javax.swing.text.JTextComponent tc)
          Adds this focus selector to the text component tc.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseEntered, mouseExited, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTextComponentFocusSelector

public JTextComponentFocusSelector(javax.swing.text.JTextComponent tc)
Creates a new JTextComponentFocusSelector and adds it as a listener to tc.

Parameters:
tc - A text component for which this focus selector will be used.
Method Detail

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

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class java.awt.event.MouseAdapter

setField

public void setField(javax.swing.text.JTextComponent tc)
Adds this focus selector to the text component tc.

Parameters:
tc - A text component for which this focus selector will be used.