Package org.jdesktop.swingx.plaf
Class SearchFieldUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.TextUI
-
- org.jdesktop.swingx.plaf.PromptTextUI
-
- org.jdesktop.swingx.plaf.PromptTextFieldUI
-
- org.jdesktop.swingx.plaf.BuddyTextFieldUI
-
- org.jdesktop.swingx.plaf.SearchFieldUI
-
public class SearchFieldUI extends BuddyTextFieldUI
The defaultJXSearchFieldUI delegate.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classSearchFieldUI.Handler-
Nested classes/interfaces inherited from class org.jdesktop.swingx.plaf.PromptTextUI
PromptTextUI.PainterHighlighter
-
-
Field Summary
Fields Modifier and Type Field Description private SearchFieldUI.Handlerhandlerstatic java.awt.InsetsNO_INSETSprotected JXSearchFieldsearchFieldThe search field that we're a UI delegate for.-
Fields inherited from class org.jdesktop.swingx.plaf.BuddyTextFieldUI
layoutAndBorder
-
Fields inherited from class org.jdesktop.swingx.plaf.PromptTextUI
delegate, focusHandler, promptComponent
-
-
Constructor Summary
Constructors Constructor Description SearchFieldUI(javax.swing.plaf.TextUI delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.JButtonclearButton()Convienence method.private voidconfigureListeners()protected BuddyLayoutAndBordercreateBuddyLayoutAndBorder()private SearchFieldUI.HandlergetHandler()protected javax.swing.IcongetNewIcon(javax.swing.Icon icon, java.lang.String resKey)Convience method for only replacing icons if they have not been customized by the user.protected intgetPopupOffset()Returns the number of pixels between the popup button and the clear (or search) button as specified in the default table by 'SearchField.popupOffset'.private booleanhasText()protected voidinstallDefaults()Initialize the search fields various properties based on the corresponding "SearchField.*" properties from defaults table.voidinstallUI(javax.swing.JComponent c)CallsinstallDefaults(), adds the search, clear and popup button to the search field and registers aPropertyChangeListeneradDocumentListenerand anActionListeneron the popup button.private booleanisMacLayoutStyle()private booleanisNativeSearchField()private voidlayoutButtons()protected javax.swing.JButtonpopupButton()Convienence method.protected javax.swing.JButtonsearchButton()Convienence method.protected booleanshouldReplaceResource(java.lang.Object o)Returns true ifoisnullor of instanceUIResource.voiduninstallUI(javax.swing.JComponent c)Removes all installed listeners, the layout and resets the search field original border and removes all children.protected voidupdateButtons()Sets the visibility of the search, clear and popup buttons depending on the search mode, layout stye, search text, search popup menu and the use of a seperate popup button.booleanusingSeperatePopupButton()ReturnstrueifJXSearchField.isUseSeperatePopupButton()istrueand a search popup menu has been set.-
Methods inherited from class org.jdesktop.swingx.plaf.BuddyTextFieldUI
getPreferredSize, paint
-
Methods inherited from class org.jdesktop.swingx.plaf.PromptTextFieldUI
createPromptComponent, getPromptComponent
-
Methods inherited from class org.jdesktop.swingx.plaf.PromptTextUI
contains, damageRange, damageRange, equals, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getEditorKit, getMaximumSize, getMinimumSize, getNextVisualPositionFrom, getRootView, getToolTipText, hashCode, modelToView, modelToView, paintPromptComponent, shouldPaintPrompt, toString, update, viewToModel, viewToModel
-
-
-
-
Field Detail
-
searchField
protected JXSearchField searchField
The search field that we're a UI delegate for. Initialized by theinstallUImethod, and reset to null byuninstallUI.
-
handler
private SearchFieldUI.Handler handler
-
NO_INSETS
public static final java.awt.Insets NO_INSETS
-
-
Method Detail
-
getHandler
private SearchFieldUI.Handler getHandler()
-
installUI
public void installUI(javax.swing.JComponent c)
CallsinstallDefaults(), adds the search, clear and popup button to the search field and registers aPropertyChangeListeneradDocumentListenerand anActionListeneron the popup button.- Overrides:
installUIin classBuddyTextFieldUI
-
configureListeners
private void configureListeners()
-
isNativeSearchField
private boolean isNativeSearchField()
-
createBuddyLayoutAndBorder
protected BuddyLayoutAndBorder createBuddyLayoutAndBorder()
- Overrides:
createBuddyLayoutAndBorderin classBuddyTextFieldUI
-
layoutButtons
private void layoutButtons()
-
isMacLayoutStyle
private boolean isMacLayoutStyle()
-
installDefaults
protected void installDefaults()
Initialize the search fields various properties based on the corresponding "SearchField.*" properties from defaults table. TheJXSearchFields layout is set to the value returned bycreateLayout. Also calls#replaceBorderIfNecessary()andupdateButtons(). This method is called byinstallUI(JComponent).- See Also:
installUI(javax.swing.JComponent),#createLayout,JXSearchField.customSetUIProperty(String, Object)
-
uninstallUI
public void uninstallUI(javax.swing.JComponent c)
Removes all installed listeners, the layout and resets the search field original border and removes all children.- Overrides:
uninstallUIin classBuddyTextFieldUI
-
shouldReplaceResource
protected boolean shouldReplaceResource(java.lang.Object o)
Returns true ifoisnullor of instanceUIResource.- Parameters:
o- an object- Returns:
- true if
oisnullor of instanceUIResource
-
getNewIcon
protected javax.swing.Icon getNewIcon(javax.swing.Icon icon, java.lang.String resKey)Convience method for only replacing icons if they have not been customized by the user. Returns the icon from the defaults table belonging toresKey, ifshouldReplaceResource(Object)with theiconas a parameter returnstrue. Otherwise returnsicon.- Parameters:
icon- the current iconresKey- the resource key identifying the default icon- Returns:
- the new icon
-
clearButton
protected final javax.swing.JButton clearButton()
Convienence method.- Returns:
- the clear button
- See Also:
JXSearchField.getCancelButton()
-
searchButton
protected final javax.swing.JButton searchButton()
Convienence method.- Returns:
- the search button
- See Also:
JXSearchField.getFindButton()
-
popupButton
protected final javax.swing.JButton popupButton()
Convienence method.- Returns:
- the popup button
- See Also:
JXSearchField.getPopupButton()
-
usingSeperatePopupButton
public boolean usingSeperatePopupButton()
ReturnstrueifJXSearchField.isUseSeperatePopupButton()istrueand a search popup menu has been set.- Returns:
- the popup button is used in addition to the search button
-
getPopupOffset
protected int getPopupOffset()
Returns the number of pixels between the popup button and the clear (or search) button as specified in the default table by 'SearchField.popupOffset'. Returns 0 ifusingSeperatePopupButton()returnsfalse- Returns:
- number of pixels between the popup button and the clear (or search) button
-
updateButtons
protected void updateButtons()
Sets the visibility of the search, clear and popup buttons depending on the search mode, layout stye, search text, search popup menu and the use of a seperate popup button. Also resets the search buttons pressed and rollover icons if the search field is in regular search mode or clears the icons when the search field is in instant search mode.
-
hasText
private boolean hasText()
-
-