Skip to content

Commit 6c09096

Browse files
committed
Put focus-losing logic into loseFocus() method
1 parent c68eb3b commit 6c09096

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,24 +231,17 @@ private void run() {
231231

232232
private void reset() {
233233
assertDispatchThread();
234-
if (dialog != null) {
234+
if (dialog == null) loseFocus();
235+
else {
235236
searchPanel = null;
236237
dialog.dispose();
237238
dialog = null;
238-
}else{
239-
SwingUtilities.getWindowAncestor(this).requestFocusInWindow();
240-
}
241-
if (!getText().isEmpty()) setText("");
242-
else {
243-
// lose the focus!
244-
loseFocus();
245-
// Toolbar.getInstance().requestFocus();
246239
}
240+
setText("");
247241
}
248242

249243
private void loseFocus() {
250-
assertDispatchThread();
251-
// NB: Default action: do nothing.
244+
SwingUtilities.getWindowAncestor(this).requestFocusInWindow();
252245
}
253246

254247
// -- Helper classes --

0 commit comments

Comments
 (0)