NativeSearchFieldSupport { public static void setSearchField(JTextField txt, boolean isSearchField) { if (isSearchField == isSearchField(txt)) { txt.putClientProperty(MAC_TEXT_FIELD_VARIANT_PROPERTY, "_triggerevent_"); } else if (isSearchField) { uiChangeHandler.install(txt); } else { uiChangeHandler.uninstall(txt); } if (isSearchField) { txt.putClientProperty(MAC_TEXT_FIELD_VARIANT_PROPERTY, MAC_SEARCH_VARIANT); txt.putClientProperty("Quaqua.TextField.style", MAC_SEARCH_VARIANT); } else { txt.putClientProperty(MAC_TEXT_FIELD_VARIANT_PROPERTY, "default"); txt.putClientProperty("Quaqua.TextField.style", "default"); } }  static boolean isNativeSearchFieldSupported(); static void setSearchField(JTextField txt, boolean isSearchField); static boolean isSearchField(JTextField txt); static boolean isNativeSearchField(JTextField txt); static void setFindPopupMenu(JTextField txt, JPopupMenu popupMenu); static JPopupMenu getFindPopupMenu(JTextField txt); static void setFindAction(JTextField txt, ActionListener findAction); static ActionListener getFindAction(JTextField txt); static void setCancelAction(JTextField txt, ActionListener cancelAction); static ActionListener getCancelAction(JTextField txt); static final String FIND_POPUP_PROPERTY; static final String FIND_ACTION_PROPERTY; static final String MAC_SEARCH_VARIANT; static final String MAC_TEXT_FIELD_VARIANT_PROPERTY; static final String CANCEL_ACTION_PROPERTY; }
@Test public void testSearchFieldPropertyChangeEvent() throws Exception { tf.addPropertyChangeListener(NativeSearchFieldSupport.MAC_TEXT_FIELD_VARIANT_PROPERTY, this); NativeSearchFieldSupport.setSearchField(tf, true); Assert.assertTrue(eventFired); eventFired = false; NativeSearchFieldSupport.setSearchField(tf, true); Assert.assertTrue(eventFired); }
@Test public void testSearchFieldUIChange() throws Exception { NativeSearchFieldSupport.setSearchField(tf, true); tf.addPropertyChangeListener(NativeSearchFieldSupport.MAC_TEXT_FIELD_VARIANT_PROPERTY, this); tf.updateUI(); Assert.assertTrue(eventFired); NativeSearchFieldSupport.setSearchField(tf, false); eventFired = false; tf.updateUI(); Assert.assertFalse(eventFired); }