void () { if (myIconsPanel.getParent() == null) { return; } boolean showClearIcon = !StringUtil.isEmpty(myTextArea.getText()); boolean showNewLine = myMultilineEnabled && myShowNewLineButton; boolean wrongVisibility = ((myClearButton.getParent() == null) == showClearIcon) || ((myNewLineButton.getParent() == null) == showNewLine); boolean multiline = StringUtil.getLineBreakCount(myTextArea.getText()) > 0; if (wrongVisibility) { myIconsPanel.removeAll(); myIconsPanel.setLayout(new BorderLayout()); myIconsPanel.add(myClearButton, BorderLayout.CENTER); if (showNewLine) myIconsPanel.add(myNewLineButton, BorderLayout.EAST); resetPreferredSize(myIconsPanel); if (!showClearIcon) myIconsPanel.remove(myClearButton); myIconsPanel.revalidate(); myIconsPanel.repaint(); } else { resetPreferredSize(myIconsPanel); } myScrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED); myScrollPane.setVerticalScrollBarPolicy(multiline ? VERTICAL_SCROLLBAR_AS_NEEDED : VERTICAL_SCROLLBAR_NEVER); myScrollPane.getHorizontalScrollBar().setVisible(multiline); myScrollPane.revalidate(); doLayout(); }