Java JTextComponent setMandatoryBackground(JTextComponent comp)

Here you can find the source of setMandatoryBackground(JTextComponent comp)

Description

Sets the text component's background to a color that shall indicate that the component's content is mandatory.

License

Open Source License

Parameter

Parameter Description
comp the text component that shall get a new background

Declaration

public static void setMandatoryBackground(JTextComponent comp) 

Method Source Code


//package com.java2s;
import java.awt.Color;

import javax.swing.text.JTextComponent;

public class Main {
    public static final Color MANDATORY_BACKGROUND = new Color(235, 235, 255);

    /**//from w  ww. ja v a 2 s .co m
     * 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&amp;feel implementation. Many l&amp;fs will honor a custom foreground color and custom border configuration.
     * However, some l&amp;fs may ignore these custom settings. It is recommended to check the appearance in all l&amp;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);
    }
}

Related

  1. safeGetText(JTextComponent textComponent)
  2. scrollToText(JTextComponent textComponent, int startingIndex, int endingIndex)
  3. scrollToTop(JTextComponent edit1)
  4. setError(JTextComponent component, boolean error)
  5. setErrorBackground(JTextComponent comp)
  6. setMandatoryBorder(JTextComponent comp)
  7. setMandatoryBorder(JTextComponent comp)
  8. setText(JTextComponent textComp, String text)
  9. setTextComponentMargins(JTextComponent component)