boolean (boolean search) { JTextComponent oldComponent = search ? mySearchTextComponent : myReplaceTextComponent; if (oldComponent != null) return false; final MyTextComponentWrapper wrapper = search ? mySearchFieldWrapper : myReplaceFieldWrapper; @NotNull JTextComponent innerTextComponent; @NotNull JComponent outerComponent; if (myMode instanceof SearchTextFieldMode mode) { outerComponent = new SearchTextField( mode.searchHistoryEnabled, mode.clearSearchActionEnabled, mode.searchHistoryEnabled ? this.toString() : null); innerTextComponent = ((SearchTextField)outerComponent).getTextEditor(); innerTextComponent.setBorder(BorderFactory.createEmptyBorder()); } else { innerTextComponent = new JBTextArea() { @Override public Dimension getPreferredScrollableViewportSize() { Dimension defaultSize = super.getPreferredScrollableViewportSize(); if (mySplitter != null && mySplitter.getSecondComponent() != null && Registry.is("ide.find.expand.search.field.on.typing", true)) { Dimension preferredSize = getPreferredSize(); Dimension minimumSize = getMinimumSize(); int spaceForLeftPanel = mySplitter.getWidth() - mySplitter.getSecondComponent().getPreferredSize().width - mySplitter.getDividerWidth(); int allSearchTextAreaIcons = JBUI.scale(180); int w = spaceForLeftPanel - allSearchTextAreaIcons; w = Math.max(w, minimumSize.width); return new Dimension(Math.min(Math.max(defaultSize.width, preferredSize.width), w), defaultSize.height); } return defaultSize; } }; ((JBTextArea)innerTextComponent).setRows(isMultiline() ? 2 : 1); ((JBTextArea)innerTextComponent).setColumns(12); innerTextComponent.setMinimumSize(new Dimension(150, 0)); SearchTextArea searchTextArea = new SearchTextArea(((JBTextArea)innerTextComponent), search); searchTextArea.setShowNewLineButton(myShowNewLineButton); outerComponent = searchTextArea; if (search) { myExtraSearchButtons.clear(); myExtraSearchButtons.addAll(searchTextArea.setExtraActions(myEmbeddedSearchActions.toArray(AnAction.EMPTY_ARRAY))); searchTextArea.setMultilineEnabled(myMultilineEnabled); } else { myExtraReplaceButtons.clear(); myExtraReplaceButtons.addAll(searchTextArea.setExtraActions(myEmbeddedReplaceActions.toArray(AnAction.EMPTY_ARRAY))); } } SwingUndoUtil.addUndoRedoActions(innerTextComponent); wrapper.setContent(outerComponent); if (search) { innerTextComponent.getAccessibleContext().setAccessibleName(FindBundle.message("find.search.accessible.name")); } else { innerTextComponent.getAccessibleContext().setAccessibleName(FindBundle.message("find.replace.accessible.name")); } // Display empty text only when focused innerTextComponent.putClientProperty( TextComponentEmptyText.STATUS_VISIBLE_FUNCTION, (Predicate<JTextComponent>)(c -> c.getText().isEmpty() && c.isFocusOwner())); innerTextComponent.putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, Boolean.TRUE); innerTextComponent.setBackground(UIUtil.getTextFieldBackground()); JComponent finalTextComponent = innerTextComponent; innerTextComponent.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { finalTextComponent.repaint(); } @Override public void focusLost(final FocusEvent e) { finalTextComponent.repaint(); } }); myCloseAction.registerOn(outerComponent); return true; }