File tree Expand file tree Collapse file tree
src/main/java/org/scijava/ui/swing/search Expand file tree Collapse file tree Original file line number Diff line number Diff line change 105105public class SwingSearchBar extends JTextField {
106106
107107 private static final String DEFAULT_MESSAGE = "Click here to search" ;
108- private static final Color ACTIVE_FONT_COLOR = new Color (0 , 0 , 0 );
108+ private static final Color DEFAULT_ACTIVE_FONT_COLOR = new Color (0 , 0 , 0 );
109+ /** Text color while typing; follows the look and feel (e.g., dark themes). */
110+ private static Color activeFontColor () {
111+ final Color c = UIManager .getColor ("TextField.foreground" );
112+ return c == null ? DEFAULT_ACTIVE_FONT_COLOR : c ;
113+ }
114+
109115 private static final Color INACTIVE_FONT_COLOR = new Color (150 , 150 , 150 );
110116 private static final Color SELECTED_RESULT_COLOR = new Color (186 , 218 , 255 );
111117 private static final String CONTEXT_COLOR = "#8C745E" ;
@@ -170,7 +176,7 @@ public void changedUpdate(final DocumentEvent e) {
170176 @ Override
171177 public void focusGained (final FocusEvent e ) {
172178 if (DEFAULT_MESSAGE .equals (getText ())) setText ("" );
173- setForeground (ACTIVE_FONT_COLOR );
179+ setForeground (activeFontColor () );
174180 }
175181
176182 @ Override
You can’t perform that action at this time.
0 commit comments