|
103 | 103 | public class SwingSearchBar extends JTextField { |
104 | 104 |
|
105 | 105 | 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); |
112 | 109 | private static final int ICON_SIZE = 16; |
113 | 110 | private static final int PAD = 5; |
114 | 111 |
|
@@ -136,7 +133,7 @@ public SwingSearchBar(final Context context) { |
136 | 133 | super(DEFAULT_MESSAGE, 12); |
137 | 134 | context.inject(this); |
138 | 135 | setText(DEFAULT_MESSAGE); |
139 | | - setForeground(SEARCHBAR_FONT_DEFAULT_COLOR); |
| 136 | + setForeground(INACTIVE_FONT_COLOR); |
140 | 137 |
|
141 | 138 | setBorder(BorderFactory.createCompoundBorder(BorderFactory |
142 | 139 | .createEmptyBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); |
@@ -167,7 +164,7 @@ public void changedUpdate(final DocumentEvent e) { |
167 | 164 | @Override |
168 | 165 | public void focusGained(final FocusEvent e) { |
169 | 166 | if (DEFAULT_MESSAGE.equals(getText())) setText(""); |
170 | | - setForeground(SEARCHBAR_FONT_COLOR); |
| 167 | + setForeground(ACTIVE_FONT_COLOR); |
171 | 168 | } |
172 | 169 |
|
173 | 170 | @Override |
@@ -306,7 +303,7 @@ private void reset() { |
306 | 303 | loseFocus(); |
307 | 304 | getDocument().removeDocumentListener(documentListener); |
308 | 305 | setText(DEFAULT_MESSAGE); |
309 | | - setForeground(SEARCHBAR_FONT_DEFAULT_COLOR); |
| 306 | + setForeground(INACTIVE_FONT_COLOR); |
310 | 307 | getDocument().addDocumentListener(documentListener); |
311 | 308 | } |
312 | 309 | else { |
@@ -377,7 +374,7 @@ public SwingSearchPanel() { |
377 | 374 | name.setEditable(false); |
378 | 375 | name.setBackground(null); |
379 | 376 | item.add(name); |
380 | | - item.setBackground(isSelected ? SELECTED_COLOR : list.getBackground()); |
| 377 | + item.setBackground(isSelected ? SELECTED_RESULT_COLOR : list.getBackground()); |
381 | 378 | return item; |
382 | 379 | }); |
383 | 380 | resultsList.setBorder(new EmptyBorder(0, 0, 0, 0)); |
|
0 commit comments