UltraLightClient Code Community
[ start | index | login ]
Overview > Select On Focus TextField

Select On Focus TextField

Belongs to following categories: Extension, ULC6.0,

Purpose

Form-based applications enable users to efficently enter or update data. The default behaviour of Swing's text field is somewhat cumbersome for such applications, though. On gaining focus JTextField (and therefore ULCTextField) just places the caret at the end of the text in a text field. Usually, it is much more convenient if the entire text gets selected as soon as the text field gains focus.

This contribution demonstrates how to adapt ULCTextField. The 5.2 version is based on Etienne's PatchedUITextField class which comes with >>Lookup TextField. The 6.0 version doesn't need that because of the vastly improved extension API. As you can see from the source code the extension is way smaller.

Resources

Related To

How to use

You instantiate, configure, and use a ULCSelectOnFocusTextField like a ULCTextField.

How it is implemented

The UISelectOnFocusTextField class serves as a proxy to the ULCSelectOnFocusTextField class. UISelectOnFocusTextField inherits from PatchedUITextField and ULCSelectOnFocusTextField inherits from ULCTextField.

UISelectOnFocusTextField features an internal class UIJTextField which overrides the standard Swing text selection business on focus gaining. In addition, UISelectOnFocusTextField handles the additional SelectOnFocus property.

The version for ULC 6.0 directly inherits from UITextField.

Compatibility

The version for ULC 5.2 has been developed and tested using JDK 1.4.2_05 and ULC 5.2 on Mac OS X 10.3.5. The version for ULC 6.0 has been developed and tested using JDK 1.4.2_09 and ULC 6.0 on Mac OS X 10.4.6.

P.S.

The current version fixes a bug where an empty text field didn't behave as expected (no selection and visible caret). ULC 5.2.1 fixes another bug: edited text fields now behave as expected on focus gained.

P.P.S.

Both versions have been updated. SelectOnFocusTextField does now work as expected when a data type is set.

Author

>>bruno

no comments | post comment
labels
Category:Extension
Category:ULC6.0
Created by bruno. Last edited by admin, 2 years and 66 days ago. Viewed 8,990 times. #41
[diff] [history] [edit] [rdf]
Name
Email:
snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt