Java JComponent Properties isMandatory(JComponent comp)

Here you can find the source of isMandatory(JComponent comp)

Description

Returns if the component has been marked as mandatory.

License

Open Source License

Parameter

Parameter Description
comp the component to be checked

Return

true if the component has been marked as mandatory

Declaration

public static boolean isMandatory(JComponent comp) 

Method Source Code

//package com.java2s;

import javax.swing.*;

public class Main {
    /**/*from   ww w . java2s .  c om*/
     * The JComponent client property key for the mandatory property 
     * that indicates whether a component's content is mandatory or optional.
     * 
     * @see #isMandatory(JComponent)
     * @see #isMandatoryAndBlank(JComponent)
     * @see #setMandatory(JComponent, boolean)
     */
    private static final String MANDATORY_KEY = "validation.isMandatory";

    /**
     * Returns if the component has been marked as mandatory.
     * 
     * @param comp    the component to be checked
     * @return true if the component has been marked as mandatory
     * 
     * @see #isMandatoryAndBlank(JComponent)
     * @see #setMandatory(JComponent, boolean)
     * @see #setMandatoryBackground(JTextComponent)
     * @see #setMandatoryBorder(JTextComponent)
     */
    public static boolean isMandatory(JComponent comp) {
        return Boolean.TRUE.equals(comp.getClientProperty(MANDATORY_KEY));
    }
}

Related

  1. getVisibleBoundsOnScreen(JComponent component)
  2. invert(JComponent c)
  3. isActive(JComponent c)
  4. isComponentShowing(final JComponent component)
  5. isHorizontallyVisible(JComponent c, int from, int to)
  6. isMarker(JComponent component)
  7. isOver(JComponent c)
  8. isOverlapping(JComponent comp1, JComponent comp2)
  9. isPasteEnabled(JComponent component)