本文整理了Java中javax.swing.text.JTextComponent.setBackground()
方法的一些代码示例,展示了JTextComponent.setBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.setBackground()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:setBackground
暂无
代码示例来源:origin: com.jgoodies/validation
/**
* Sets the text component's background to a color that shall indicate
* that the component's content is invalid with warning severity.<p>
*
* <strong>Note:</strong> The component background colors are
* managed by the look&feel implementation. Many l&fs will honor a
* custom foreground color and custom border configuration. However, some
* l&fs may ignore these custom settings. It is recommended to check
* the appearance in all l&fs available in an application.
*
* @param comp the text component that shall get a new background
*
* @see #setMandatoryBackground(JTextComponent)
* @see #setErrorBackground(JTextComponent)
*/
public static void setWarningBackground(JTextComponent comp) {
comp.setBackground(WARNING_BACKGROUND);
}
代码示例来源:origin: com.jgoodies/jgoodies-validation
/**
* Sets the text component's background to a color that shall indicate
* that the component's content is invalid with warning severity.<p>
*
* <strong>Note:</strong> The component background colors are
* managed by the look&feel implementation. Many l&fs will honor a
* custom foreground color and custom border configuration. However, some
* l&fs may ignore these custom settings. It is recommended to check
* the appearance in all l&fs available in an application.
*
* @param comp the text component that shall get a new background
*
* @see #setMandatoryBackground(JTextComponent)
* @see #setErrorBackground(JTextComponent)
*/
public static void setWarningBackground(JTextComponent comp) {
comp.setBackground(WARNING_BACKGROUND);
}
代码示例来源:origin: com.jgoodies/jgoodies-validation
/**
* Sets the text component's background to a color that shall indicate
* that the component's content is mandatory.<p>
*
* <strong>Note:</strong> The component background colors are
* managed by the look&feel implementation. Many l&fs will honor a
* custom foreground color and custom border configuration. However, some
* l&fs may ignore these custom settings. It is recommended to check
* the appearance in all l&fs available in an application.
*
* @param comp the text component that shall get a new background
*
* @see #setMandatoryBorder(JTextComponent)
* @see #setErrorBackground(JTextComponent)
* @see #setWarningBackground(JTextComponent)
*/
public static void setMandatoryBackground(JTextComponent comp) {
comp.setBackground(MANDATORY_BACKGROUND);
}
代码示例来源:origin: pentaho/pentaho-reporting
protected void convert() {
try {
final String text = textComponent.getText();
textComponent.setBackground( color );
final Date date = convertValue( text );
TimeCellEditor.this.date = date;
} catch ( Exception e ) {
// ignore, do not update (yet).
textComponent.setBackground( Color.RED );
} finally {
inProgress = false;
}
}
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
protected void clear() {
textComponent.setBackground(defaultBGColor);
textComponent.setToolTipText(defaultToolTip);
}
}
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
protected void clear() {
textComponent.setBackground(defaultBGColor);
textComponent.setToolTipText(defaultToolTip);
}
}
代码示例来源:origin: pentaho/pentaho-reporting
protected void convert( final boolean autoUpdate ) {
try {
final String text = textComponent.getText();
textComponent.setBackground( color );
updateContext.setParameterValue( keyName, convertValue( text ), autoUpdate );
} catch ( BeanException e ) {
// ignore, do not update (yet).
textComponent.setBackground( Color.RED );
} finally {
inProgress = false;
}
}
代码示例来源:origin: com.jgoodies/validation
/**
* Looks up and restores the text component's previously stored (original)
* background color.
*
* @param comp the component that shall get its original background color
*
* @see #getStoredBackground(JTextComponent)
* @see #ensureCustomBackgroundStored(JTextComponent)
*/
private static void restoreBackground(JTextComponent comp) {
Color storedBackground = getStoredBackground(comp);
comp.setBackground(storedBackground == null
? getDefaultBackground(comp)
: storedBackground);
}
代码示例来源:origin: com.jgoodies/jgoodies-validation
/**
* Looks up and restores the text component's previously stored (original)
* background color.
*
* @param comp the component that shall get its original background color
*
* @see #getStoredBackground(JTextComponent)
* @see #ensureCustomBackgroundStored(JTextComponent)
*/
private static void restoreBackground(JTextComponent comp) {
Color storedBackground = getStoredBackground(comp);
comp.setBackground(storedBackground == null
? getDefaultBackground(comp)
: storedBackground);
}
代码示例来源:origin: zgqq/mah
@Override
public void apply(LayoutTheme theme) {
if (theme instanceof SwingLayoutTheme) {
SwingLayoutTheme layoutTheme = (SwingLayoutTheme) theme;
String panelBackgroundColor = layoutTheme.findProperty("background-color");
panel.setBackground(Color.decode(panelBackgroundColor));
String inputFieldBackgroundColor = layoutTheme.findProperty("input-field-background-color");
input.setBackground(Color.decode(inputFieldBackgroundColor));
String fontColor = layoutTheme.findProperty("input-field-font-color");
input.setForeground(Color.decode(fontColor));
String cursorColor = layoutTheme.findProperty("input-cursor-color");
input.setCaretColor(Color.decode(cursorColor));
}
}
代码示例来源:origin: com.jtattoo/JTattoo
private void updateBackground() {
JTextComponent c = getComponent();
if (c.getBackground() instanceof UIResource) {
if (!c.isEnabled() || !c.isEditable()) {
c.setBackground(AbstractLookAndFeel.getDisabledBackgroundColor());
} else {
c.setBackground(AbstractLookAndFeel.getInputBackgroundColor());
}
}
}
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
public static void configuraWebLaf(JTextComponent field) {
if (!WeblafUtils.weblafEstaInstalado()) {
return;
}
// ((WebTextAreaUI) field.getUI()).setDrawBorder(false);
// ((WebTextAreaUI) field.getUI()).setDrawBackground(true);
field.setBorder(new EmptyBorder(15,15,15,15));
field.setOpaque(true);
field.setBackground(ColorController.COR_DESTAQUE);
field.setForeground(ColorController.COR_LETRA);
}
public static void configuraWebLaf(JProgressBar field) {
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
public void updateModel() {
try {
updateModel(textComponent.getText());
clear();
}
catch (ValidationException vex) {
textComponent.setBackground(errorColor);
textComponent.setToolTipText(vex.getUnlabeledMessage());
}
}
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
protected void updateModel() {
try {
setValue(textComponent.getText());
clear();
}
catch (ValidationException vex) {
textComponent.setBackground(errorColor);
textComponent.setToolTipText(vex.getUnlabeledMessage());
}
}
代码示例来源:origin: com.jtattoo/JTattoo
private void updateBackground() {
JTextComponent c = getComponent();
if (c.getBackground() instanceof UIResource) {
if (!c.isEnabled() || !c.isEditable()) {
c.setBackground(AbstractLookAndFeel.getDisabledBackgroundColor());
} else {
c.setBackground(AbstractLookAndFeel.getInputBackgroundColor());
}
}
}
}
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
protected void validate() {
try {
validate(textComponent.getText());
clear();
} catch (ValidationException vex) {
textComponent.setBackground(errorColor);
textComponent.setToolTipText(wrapTooltip(vex.getUnlabeledMessage()));
}
}
代码示例来源:origin: jsettlers/settlers-remake
/**
* Install the border
*
* @param txt
* Text component
*/
public static void installUi(JTextComponent txt) {
txt.setOpaque(false);
Insets margin = txt.getMargin();
if (margin == null) {
margin = new Insets(5, 5, 5, 5);
}
Border marginBorder = BorderFactory.createEmptyBorder(margin.top + 3, margin.left, margin.bottom + 3, margin.right);
CompoundBorder border = new CompoundBorder(BorderFactory.createLineBorder(Color.WHITE), marginBorder);
txt.setBorder(border);
txt.setBackground(Color.BLUE);
txt.setForeground(Color.WHITE);
txt.setSelectionColor(SELECTION_COLOR);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
private void prepareEditor() {
Component c = getEditor().getEditorComponent();
if (c instanceof JTextComponent) {
JTextComponent jtc = (JTextComponent) c;
String s = jtc.getText();
if (s != null && s.length() > 0){
jtc.setSelectionStart(0);
jtc.setSelectionEnd(s.length());
}
if (tableUI) {
jtc.setBackground(getBackground());
} else {
jtc.setBackground(PropUtils.getTextFieldBackground());
}
}
if (getLayout() != null) {
getLayout().layoutContainer(this);
}
repaint();
}
代码示例来源:origin: com.eas.platypus/platypus-js-scalable-widget
protected void clearEditingTexts() {
Iterator<JTextComponent> lit = editingTexts.iterator();
if (lit != null) {
while (lit.hasNext()) {
JTextComponent ltc = lit.next();
ltc.putClientProperty(TEXT_COMPS_EDITABLE, ltc.isEditable());
ltc.putClientProperty(TEXT_COMPS_BACKGROUND, ltc.getBackground());
ltc.putClientProperty(TEXT_COMPS_HINT, ltc.getToolTipText());
ltc.setEditable(false);
ltc.setBackground(Color.lightGray);
ltc.setToolTipText(localizations.getString("Click2Edit"));
if (ltc.getCaret() != null) {
ltc.getCaret().setVisible(false);
}
}
}
editingTexts.clear();
}
代码示例来源:origin: net.sf.sfac/sfac-core
@Override
protected void synchronizeEditableState() {
if (textField != null) {
textField.setEditable(isEditable());
textField.setEnabled(isEnabled());
if (isMultiline()) {
textField.setBackground(isEditable() ? Color.WHITE : Color.LIGHT_GRAY);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!