diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java index 83cb7ee6..a8ba969b 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatFindReplaceBar.java @@ -84,23 +84,21 @@ class FlatFindReplaceBar @Override public boolean requestFocusInWindow() { // invoked from CollapsibleSectionPanel - return findField.requestFocusInWindow(); - } - - @Override - public void addNotify() { - super.addNotify(); // if showing bar, highlight matches in editor + // (not invoking this from addNotify() because this would break the slide-in animation) markAll(); + + return findField.requestFocusInWindow(); } @Override public void removeNotify() { super.removeNotify(); - // if hiding bar, clear all highlighted matches in editor + // if hiding bar, clear all highlighted matches in editor and focus it SearchEngine.markAll( textArea, new SearchContext() ); + textArea.requestFocusInWindow(); } private void findNext() { diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java index 28ca332f..836e1ce5 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java @@ -109,18 +109,8 @@ class FlatThemeEditorPane // create overlay layer JLayer overlay = new JLayer<>( textArea, new FlatThemeEditorOverlay() ); - // create view panel that transfers focus to editor when hiding find/replace bar - JPanel viewPanel = new JPanel( new BorderLayout() ) { - @Override - public boolean requestFocusInWindow() { - // invoked from CollapsibleSectionPanel - return textArea.requestFocusInWindow(); - } - }; - viewPanel.add( overlay, BorderLayout.CENTER ); - // create scroll pane - scrollPane = new RTextScrollPane( viewPanel ); + scrollPane = new RTextScrollPane( overlay ); scrollPane.setBorder( null ); scrollPane.setLineNumbersEnabled( true );