JComponent (@NlsContexts.Label String mainText, @Nls String errorText, boolean hasError) { SimpleColoredComponent component = new SimpleColoredComponent(); if (hasError) { component.append(mainText + " (" + errorText + ")", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.RED)); } else { component.append(mainText); } return component; }