JEditorPane () { final JEditorPane textPane = new JEditorPane() { private boolean myEnabled = true; private String myEnabledHtml; @Override public Dimension getPreferredSize() { // This trick makes text component to carry text over to the next line // if the text line width exceeds parent's width Dimension dimension = super.getPreferredSize(); if (myCarryTextOver) { dimension.width = 0; } return dimension; } @Override public void setText(@NlsSafe String t) { if (myDisabledHtml != null) { if (myEnabled) { myEnabledHtml = t; } } super.setText(t); } @Override public void setEnabled(boolean enabled) { if (myDisabledHtml != null) { myEnabled = enabled; if (myEnabled) { setText(myEnabledHtml); } else { setText(myDisabledHtml); } super.setEnabled(true); } else { super.setEnabled(enabled); } } }; textPane.setFont(myFont != null ? myFont : StartupUiUtil.getLabelFont()); textPane.setEditorKit(HTMLEditorKitBuilder.simple()); textPane.setEditable(false); if (myBackground != null) { textPane.setBackground(myBackground); } else { textPane.setOpaque(false); } textPane.setForeground(myForeground != null ? myForeground : UIUtil.getLabelForeground()); textPane.setFocusable(false); return textPane; }