Code example for JLabel

Methods: setLabelFor

0
            throw new IllegalArgumentException(
                    "You must provide two CellConstraints instances, " + 
                    "one for the label and one for the component.\n" + 
                	"Consider using #clone(). See the JavaDocs for details."); 
 
        add(label,     labelConstraints);
        add(component, componentConstraints);
        label.setLabelFor(component);
        return label;
    } 
 
 
    /** 
     * Adds a label and component to the panel using the given cell constraints. 
     * Sets the given label as <i>the</i> component label using 
     * {@link JLabel#setLabelFor(java.awt.Component)}.<p> 
     * 
     * <strong>Note:</strong> The {@link CellConstraints} objects for the label 
     * and the component must be different. Cell constraints are implicitly 
     * cloned by the <code>FormLayout</code> when added to the container.