Text Fields

Text Field Styles

VAqua supports two custom styles of text fields, which are selected by setting the JTextField.style client property. In addition, any text field used on a toolbar displays in the style of a textured button.

Setting the JTextField.style client property to round changes the text field border to have rounded corners.

Setting the JTextField.style client property to search changes the text field to display as a search field. A search field displays a magnifying glass icon, with an optional menu icon. When the search field is empty, it optionally displays a prompt. When the search field text is not empty, it displays a cancel button.

The menu icon is displayed when the text field is focused if a menu has been defined for the text field. To define a menu, set the JTextField.Search.FindPopup client property to a JPopUpMenu.

The prompt text is specified as the value of the JTextField.Search.Prompt client property. Any object may be used. It will be converted to text using the toString() method.

Action listeners may be provided that are invoked when the magnifying glass icon or the cancel button is clicked by setting the JTextField.Search.FindAction and JTextField.Search.CancelAction client properties, respectively. If the JTextField.Search.FindAction property is not defined, clicking on the magnifying glass icon will perform the text field action.

Size Options

Text fields support several size options, specified using the JComponent.sizeVariant client property with values regular (the default), small, or mini. The size option affects the default font. For the round and search styles, which have a fixed height, the fixed height depends upon the size option.