Java Swing LineBorder getMandatoryBorder()

Here you can find the source of getMandatoryBorder()

Description

Lazily creates and returns a Border instance that is used to indicate that a component's content is mandatory.

License

Open Source License

Return

a Border that is used to indicate that a component's content is mandatory

Declaration

public static Border getMandatoryBorder() 

Method Source Code


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

import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;

import javax.swing.plaf.basic.BasicBorders;

public class Main {
    private static final Color MANDATORY_FOREGROUND = new Color(70, 70, 210);
    /**//from ww  w . ja  va2s. c  o m
     * Holds a cached Border that is used to indicate mandatory text components.
     * It will be lazily created in method {@link #getMandatoryBorder()}.
     * 
     * @see #getMandatoryBorder()
     * @see #setMandatoryBorder(JTextComponent)
     */
    private static Border mandatoryBorder;

    /**
     * Lazily creates and returns a {@link Border} instance that is used
     * to indicate that a component's content is mandatory.
     * 
     * @return a <code>Border</code> that is used to indicate that 
     *     a component's content is mandatory
     */
    public static Border getMandatoryBorder() {
        if (mandatoryBorder == null) {
            mandatoryBorder = new CompoundBorder(new LineBorder(getMandatoryForeground()),
                    new BasicBorders.MarginBorder());
        }
        return mandatoryBorder;
    }

    /**
     * Returns a default foreground color that can be used as the component 
     * foreground for components with mandatory content. Typically this
     * color will be used with instances of {@link JTextComponent}.<p>
     * 
     * <strong>Note:</strong> The component foreground and border 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.
     * 
     * @return a foreground color useful for components with mandatory content
     * 
     * @see #getMandatoryBackground()
     * @see #getMandatoryBorder()
     */
    public static Color getMandatoryForeground() {
        return MANDATORY_FOREGROUND;
    }
}

Related

  1. createThickInsetBorder()
  2. drawBorders(final JPanel panel)
  3. getBorderBlue()
  4. getDefaultLineBorder()
  5. getLineBorder()
  6. getToolTipBorder()
  7. intToBorder(int borderConstant)
  8. isAtScrollPaneRightBorder(Component c, int x)
  9. lineBorder(JComponent comp)