ExtendableTextField (boolean liveErrorValidation) { ExtendableTextField res = createNonCustomizedTextField(); Dimension minSize = res.getMinimumSize(); Dimension prefSize = res.getPreferredSize(); minSize.height = JBUIScale.scale(28); prefSize.height = JBUIScale.scale(28); res.setMinimumSize(minSize); res.setPreferredSize(prefSize); res.setColumns(30); Border border = JBUI.Borders.customLine(JBUI.CurrentTheme.NewClassDialog.bordersColor(), 1, 0, 0, 0); Border errorBorder = new ErrorBorder(res.getBorder()); res.setBorder(JBUI.Borders.merge(border, errorBorder, false)); res.setBackground(JBUI.CurrentTheme.NewClassDialog.searchFieldBackground()); res.putClientProperty(TextComponentEmptyText.STATUS_VISIBLE_FUNCTION, (Predicate<JBTextField>)field -> field.getText().isEmpty()); res.getEmptyText().setText(IdeBundle.message("action.create.new.class.name.field")); res.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (myApplyAction == null) return; try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) { myApplyAction.consume(e); } } } }); res.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { if (!liveErrorValidation) setError(null); } }); return res; }