|
74 | 74 | import javax.swing.SwingUtilities; |
75 | 75 | import javax.swing.ToolTipManager; |
76 | 76 | import javax.swing.UIManager; |
| 77 | +import javax.swing.border.EmptyBorder; |
77 | 78 | import javax.swing.event.ChangeEvent; |
78 | 79 | import javax.swing.event.DocumentEvent; |
79 | 80 | import javax.swing.event.DocumentListener; |
@@ -200,7 +201,6 @@ void runInteractively() { |
200 | 201 |
|
201 | 202 | // Create search prompt |
202 | 203 | prompt = new JTextField(PROMPT_PLACEHOLDER); |
203 | | - prompt.setFont(prompt.getFont().deriveFont(15f)); |
204 | 204 | prompt.selectAll(); |
205 | 205 | prompt.getDocument().addDocumentListener(this); |
206 | 206 | prompt.addActionListener(this); |
@@ -262,22 +262,26 @@ public void itemStateChanged(final ItemEvent ie) { |
262 | 262 |
|
263 | 263 | // Create the 'history' button and blend it with prompt |
264 | 264 | final Icon icon = UIManager.getIcon("Table.descendingSortIcon"); |
265 | | - historyButton = new JButton(" ", icon); |
| 265 | + historyButton = new JButton(icon); |
266 | 266 | historyButton.setBackground(prompt.getBackground()); |
267 | | - historyButton.setBorder(null); |
| 267 | + historyButton.setBorder(new EmptyBorder(0, 0, 0, 4)); |
268 | 268 | historyButton.addActionListener(this); |
269 | 269 |
|
270 | | - // Create search panel: a unified component with looking like a JTextField |
| 270 | + // Create search panel: a unified component looking like a JTextField |
271 | 271 | final JPanel promptPanel = new JPanel(new BorderLayout()); |
272 | 272 | promptPanel.add(prompt, BorderLayout.CENTER); |
273 | 273 | promptPanel.add(historyButton, BorderLayout.LINE_END); |
274 | 274 | promptPanel.setBackground(prompt.getBackground()); |
275 | 275 | promptPanel.setBorder(prompt.getBorder() ); |
276 | | - prompt.setBorder(null); |
277 | 276 |
|
278 | | - // Place everything into a final container |
| 277 | + prompt.setBorder(new EmptyBorder(4, 4, 4, 4)); |
| 278 | + prompt.setFont(prompt.getFont().deriveFont(15f)); |
| 279 | + historyButton.setContentAreaFilled(false); |
| 280 | + |
| 281 | + // Place all search-related components into a final container |
279 | 282 | final JPanel searchPanel = new JPanel(new BorderLayout()); |
280 | | - searchPanel.add(promptPanel, BorderLayout.CENTER); |
| 283 | + promptPanel.validate(); |
| 284 | + searchPanel.add(promptPanel, BorderLayout.CENTER); |
281 | 285 | searchPanel.add(cboxPanel, BorderLayout.PAGE_END); |
282 | 286 | searchPanel.setFocusable(true); |
283 | 287 |
|
@@ -533,7 +537,7 @@ void showHistoryMenu() { |
533 | 537 | mi.addActionListener(al); |
534 | 538 | popup.add(mi); |
535 | 539 | } |
536 | | - popup.show(historyButton, historyButton.getWidth() / 2, 0); |
| 540 | + popup.show(historyButton, 0, 0); |
537 | 541 | } |
538 | 542 |
|
539 | 543 | /** |
|
0 commit comments