JIDE 3.5.15

com.jidesoft.swing
Class SelectAllUtils

java.lang.Object
  extended by com.jidesoft.swing.SelectAllUtils

public class SelectAllUtils
extends Object

SelectAllUtils is a utility class to select all the text in a text component when the component first time receives focus. It's very easy to use it.


 JTextField field = new JTextField();
 SelectAllUtils.install(field);
 
The component you pass in can be a JTextComponent or any container that contains one or more JTextComponents. All JTextComponents will be installed such a focus listener to select all when it gets focus for the first time. For example, you can install it to an editable JComboBox.

 JComboBox comboBox = new JComboBox();
 comboBox.setEditable(true);
 SelectAllUtils.install(comboBox);
 
Although JComboBox is not JTextComponent but it contains a JTextField so it will still work. However please make sure call it after the call to comboBox.setEditable(true). Otherwise it will not work because JTextField is not created until setEditable(true) is called.


Field Summary
static String CLIENT_PROPERTY_ONLYONCE
          A client property.
 
Constructor Summary
SelectAllUtils()
           
 
Method Summary
static void install(Component component)
          Installs focus listener to all text components inside the component.
static void install(Component component, boolean onlyOnce)
          Installs focus listener to all text components inside the component.
static void uninstall(Component component)
          Uninstalls focus listener to all text components inside the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_PROPERTY_ONLYONCE

public static final String CLIENT_PROPERTY_ONLYONCE
A client property. If set to Boolean.TRUE, we will only select all the text just for the first time when the component gets focus.

See Also:
Constant Field Values
Constructor Detail

SelectAllUtils

public SelectAllUtils()
Method Detail

install

public static void install(Component component)
Installs focus listener to all text components inside the component. This focus listener will select all the text when it gets focus.

Parameters:
component - the component to make it select all when having focus. The component could be a JTextComponent or could be a container that contains one or more JTextComponents. This install method will make all JTextComponents to have this select all feature.

install

public static void install(Component component,
                           boolean onlyOnce)
Installs focus listener to all text components inside the component. This focus listener will select all the text when it gets focus.

Parameters:
component - the component to make it select all when having focus. The component could be a JTextComponent or could be a container that contains one or more JTextComponents. This install method will make all JTextComponents to have this select all feature.
onlyOnce - if true, we will only select all the text when the component has focus for the first time. Otherwise, it will always select all the text whenever the component receives focus.

uninstall

public static void uninstall(Component component)
Uninstalls focus listener to all text components inside the component.

Parameters:
component - the component which install(java.awt.Component) is called.

JIDE 3.5.15