Here you can find the source of isMandatory(JComponent comp)
Parameter | Description |
---|---|
comp | the component to be checked |
public static boolean isMandatory(JComponent comp)
//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)); } }