Java Utililty Methods JTextComponent

List of utility methods to do JTextComponent

Description

The list of methods to do JTextComponent are organized into topic(s).

Method

voidsetTextStyle(JTextComponent txt)
set Text Style
getBasicFont();
txt.setFont(BASIC_FONT);
txt.setForeground(BASIC_TEXT_COLOR);
txt.setBackground(BACKGROUND);
voidsetWarningBackground(JTextComponent comp)
Sets the text component's background to a color that shall indicate that the component's content is invalid with warning severity.

Note: The component background colors are managed by the look&feel implementation.

comp.setBackground(WARNING_BACKGROUND);
JTextComponenttextComponentAsLabel(JTextComponent textcomponent)
This will allow selection and copy to work but still retain the label look
textcomponent.setEditable(false);
textcomponent.setBackground((Color) UIManager.get("Label.background"));
textcomponent.setForeground((Color) UIManager.get("Label.foreground"));
textcomponent.setBorder(null);
return textcomponent;
Stringvalue(JTextComponent txt)
value
return txt.getText();