| |
|
| java.lang.Object com.jidesoft.swing.SelectAllUtils
SelectAllUtils | public class SelectAllUtils (Code) | | 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.
|
Method Summary | |
public static void | install(Component component) Installs focus listener to all text components inside the component. | public static void | install(Component component, boolean onlyOnce) Installs focus listener to all text components inside the component. | public static void | uninstall(Component component) Uninstalls focus listener to all text components inside the component. |
CLIENT_PROPERTY_ONLYONCE | final public static String CLIENT_PROPERTY_ONLYONCE(Code) | | 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.
|
install | public static void install(Component component)(Code) | | 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 bea container that contains one or more JTextComponents. This install method will make all JTextComponentsto have this select all feature. |
install | public static void install(Component component, boolean onlyOnce)(Code) | | 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 bea container that contains one or more JTextComponents. This install method will make all JTextComponentsto have this select all feature. Parameters: onlyOnce - if true, we will only select all the text when the component has focus for the first time. Otherwise, it willalways select all the text whenever the component receives focus. |
|
|
|