Skip to content

Commit edcffd3

Browse files
committed
SwingSearchBar: clean up constants
1 parent 7651ead commit edcffd3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/main/java/org/scijava/ui/swing/search/SwingSearchBar.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,9 @@
103103
public class SwingSearchBar extends JTextField {
104104

105105
private static final String DEFAULT_MESSAGE = "Click here to search";
106-
107-
private static final Color SEARCHBAR_FONT_COLOR = new Color(0, 0, 0);
108-
private static final Color SEARCHBAR_FONT_DEFAULT_COLOR = new Color(150, 150,
109-
150);
110-
111-
private static final Color SELECTED_COLOR = new Color(70, 152, 251);
106+
private static final Color ACTIVE_FONT_COLOR = new Color(0, 0, 0);
107+
private static final Color INACTIVE_FONT_COLOR = new Color(150, 150, 150);
108+
private static final Color SELECTED_RESULT_COLOR = new Color(70, 152, 251);
112109
private static final int ICON_SIZE = 16;
113110
private static final int PAD = 5;
114111

@@ -136,7 +133,7 @@ public SwingSearchBar(final Context context) {
136133
super(DEFAULT_MESSAGE, 12);
137134
context.inject(this);
138135
setText(DEFAULT_MESSAGE);
139-
setForeground(SEARCHBAR_FONT_DEFAULT_COLOR);
136+
setForeground(INACTIVE_FONT_COLOR);
140137

141138
setBorder(BorderFactory.createCompoundBorder(BorderFactory
142139
.createEmptyBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
@@ -167,7 +164,7 @@ public void changedUpdate(final DocumentEvent e) {
167164
@Override
168165
public void focusGained(final FocusEvent e) {
169166
if (DEFAULT_MESSAGE.equals(getText())) setText("");
170-
setForeground(SEARCHBAR_FONT_COLOR);
167+
setForeground(ACTIVE_FONT_COLOR);
171168
}
172169

173170
@Override
@@ -306,7 +303,7 @@ private void reset() {
306303
loseFocus();
307304
getDocument().removeDocumentListener(documentListener);
308305
setText(DEFAULT_MESSAGE);
309-
setForeground(SEARCHBAR_FONT_DEFAULT_COLOR);
306+
setForeground(INACTIVE_FONT_COLOR);
310307
getDocument().addDocumentListener(documentListener);
311308
}
312309
else {
@@ -377,7 +374,7 @@ public SwingSearchPanel() {
377374
name.setEditable(false);
378375
name.setBackground(null);
379376
item.add(name);
380-
item.setBackground(isSelected ? SELECTED_COLOR : list.getBackground());
377+
item.setBackground(isSelected ? SELECTED_RESULT_COLOR : list.getBackground());
381378
return item;
382379
});
383380
resultsList.setBorder(new EmptyBorder(0, 0, 0, 0));

0 commit comments

Comments
 (0)