public class QuickSearchField
extends javax.swing.JTextField
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.border.Border
QuickSearchField is a componet like the Cocoa NSSearchField.
If the componet has no focus and no text form a user input, it shows the
default text. If the user has entered any text, a cancel icon is shown.
By clicking on the cancle icon the user input is reset to the default settings.
You also can set a JPopupMenu that is show if the user clicks the search icon.javax.swing.JTextField.AccessibleJTextFieldjavax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBindingjavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROP_DEFAULT_SEARCH_COLOR |
static java.lang.String |
PROP_DEFAULT_SEARCH_FONT |
static java.lang.String |
PROP_DEFAULT_SEARCH_TEXT |
static java.lang.String |
PROP_POPUP_MENU |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT| Constructor and Description |
|---|
QuickSearchField(java.awt.Color outerColor)
Constructs a new QuickSearchField
|
QuickSearchField(javax.swing.Icon searchIcon,
javax.swing.Icon cancelIcon)
Constructs a new QuickSearchField initialized with the specified default
text, search Icon and Cancel Icon
|
QuickSearchField(javax.swing.Icon searchIcon,
javax.swing.Icon cancelIcon,
javax.swing.JPopupMenu popupMenu,
java.awt.Color outerColor)
Constructs a new QuickSearchField initialized with the specified default
text, search Icon, Cancel Icon
and PopupMenu.
|
| Modifier and Type | Method and Description |
|---|---|
java.awt.Insets |
getBorderInsets(java.awt.Component c) |
javax.swing.Icon |
getCancelIcon()
Gets the cancel icon
|
javax.swing.Icon |
getCancelIconPressed()
Gets the pressed cancel icon
|
java.lang.String |
getEmptyText()
Gets the text that is displayed when there is no input in the field.
|
java.awt.Dimension |
getMinimumSize() |
javax.swing.JPopupMenu |
getPopupMenu()
Gets the JPopupMenu, this is show if the user clicks on the searchIcon
|
java.awt.Dimension |
getPreferredSize() |
javax.swing.Icon |
getSearchIcon()
Gets the search icon
|
javax.swing.Icon |
getSearchIconPressed()
Gets the pressed search icon
|
boolean |
isBorderOpaque() |
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
paintBorder(java.awt.Component c,
java.awt.Graphics g,
int x,
int y,
int width,
int height) |
void |
paintComponent(java.awt.Graphics g) |
void |
setCancelIcon(javax.swing.Icon value)
Sets a cancel icon
|
void |
setCancelIconPressed(javax.swing.Icon value)
Sets a pressed cancel icon
|
void |
setEmptyText(java.lang.String newEmptyText)
Sets the default text, this text is shown if the component has no focus
and the user has not entered any text.
|
void |
setPopupMenu(javax.swing.JPopupMenu value)
Sets a JPopupMenu, this is show if the user clicks on the searchIcon
|
void |
setSearchIcon(javax.swing.Icon value)
Sets a search icon
|
void |
setSearchIconPressed(javax.swing.Icon value)
Sets a pressed search icon
|
java.lang.String |
toString() |
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffsetaddCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, writeaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final java.lang.String PROP_DEFAULT_SEARCH_TEXT
public static final java.lang.String PROP_DEFAULT_SEARCH_FONT
public static final java.lang.String PROP_DEFAULT_SEARCH_COLOR
public static final java.lang.String PROP_POPUP_MENU
public QuickSearchField(java.awt.Color outerColor)
public QuickSearchField(javax.swing.Icon searchIcon,
javax.swing.Icon cancelIcon)
public QuickSearchField(javax.swing.Icon searchIcon,
javax.swing.Icon cancelIcon,
javax.swing.JPopupMenu popupMenu,
java.awt.Color outerColor)
public java.lang.String toString()
toString in class java.awt.Componentpublic void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentpublic java.lang.String getEmptyText()
public void setEmptyText(java.lang.String newEmptyText)
public javax.swing.JPopupMenu getPopupMenu()
public void setPopupMenu(javax.swing.JPopupMenu value)
public javax.swing.Icon getSearchIcon()
public void setSearchIcon(javax.swing.Icon value)
public javax.swing.Icon getCancelIcon()
public void setCancelIcon(javax.swing.Icon value)
public javax.swing.Icon getSearchIconPressed()
public void setSearchIconPressed(javax.swing.Icon value)
public javax.swing.Icon getCancelIconPressed()
public void setCancelIconPressed(javax.swing.Icon value)
public java.awt.Dimension getMinimumSize()
getMinimumSize in class javax.swing.JComponentpublic java.awt.Dimension getPreferredSize()
getPreferredSize in class javax.swing.JTextFieldpublic java.awt.Insets getBorderInsets(java.awt.Component c)
getBorderInsets in interface javax.swing.border.Borderpublic boolean isBorderOpaque()
isBorderOpaque in interface javax.swing.border.Borderpublic void paintBorder(java.awt.Component c,
java.awt.Graphics g,
int x,
int y,
int width,
int height)
paintBorder in interface javax.swing.border.Borderpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListener