/** * @see sun.swing.plaf.synth.SynthUI#paintBorder(javax.swing.plaf.synth.SynthContext, * java.awt.Graphics, int, int, int, int) */ public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { ((SeaGlassContext) context).getPainter().paintTextFieldBorder(context, g, x, y, w, h); JTextComponent c = getComponent(); if (isSearchField.isInState(c)) { paintSearchButton(g, c, SeaGlassRegion.SEARCH_FIELD_FIND_BUTTON); paintSearchButton(g, c, SeaGlassRegion.SEARCH_FIELD_CANCEL_BUTTON); } }
/** * Sea Glass code to support the search JTextField.variant. * * @param c the JTextField component. * @param context the SeaGlassContext. * @param prefix the control prefix, e.g. "TextField", "FormattedTextField", or "PasswordField". */ private void updateSearchStyle(JTextComponent c, SeaGlassContext context, String prefix) { searchIconWidth = 0; Object o = style.get(context, prefix + ".searchIconWidth"); if (o != null && o instanceof Integer) { searchIconWidth = (Integer) o; } popupIconWidth = 0; o = style.get(context, prefix + ".popupIconWidth"); if (o != null && o instanceof Integer) { popupIconWidth = (Integer) o; } cancelIconWidth = 0; o = style.get(context, prefix + ".cancelIconWidth"); if (o != null && o instanceof Integer) { cancelIconWidth = (Integer) o; } searchLeftInnerMargin = 0; o = style.get(context, prefix + ".searchLeftInnerMargin"); if (o != null && o instanceof Integer) { searchLeftInnerMargin = (Integer) o; } searchRightInnerMargin = 0; o = style.get(context, prefix + ".searchRightInnerMargin"); if (o != null && o instanceof Integer) { searchRightInnerMargin = (Integer) o; } placeholderColor = Color.GRAY; o = style.get(context, "placeholderTextColor"); if (o != null && o instanceof Color) { placeholderColor = (Color) o; } Border border = c.getBorder(); if (border == null || border instanceof UIResource && !(border instanceof TextFieldBorder)) { c.setBorder(createTextFieldBorder(context)); } if (isSearchField.isInState(c)) { o = c.getClientProperty("JTextField.Search.PlaceholderText"); if (o != null && o instanceof String) { placeholderText = (String) o; } else if (placeholderText != null) { placeholderText = null; } o = c.getClientProperty("JTextField.Search.FindAction"); if (o != null && o instanceof ActionListener) { if (findAction == null) { findAction = (ActionListener) o; } } o = c.getClientProperty("JTextField.Search.FindPopup"); if (o != null && o instanceof JPopupMenu) { if (findPopup == null) { findPopup = (JPopupMenu) o; } } o = c.getClientProperty("JTextField.Search.CancelAction"); if (o != null && o instanceof ActionListener) { if (cancelAction == null) { cancelAction = (ActionListener) o; } } installMouseListeners(); } else { placeholderText = null; if (findAction != null) { findAction = null; } if (findPopup != null) { findPopup = null; } if (cancelAction != null) { cancelAction = null; } uninstallMouseListeners(); } }