FormLayout layout = (FormLayout)contentPane.getLayout(); cc = layout.getConstraints(myLabel); cc.vAlign = CellConstraints.DEFAULT; layout.setConstraints(myLabel, cc);
/** * Adds the specified component to the layout, using the specified * <code>constraints</code> object. Note that constraints are mutable and * are, therefore, cloned when cached. * * @param comp the component to be added * @param constraints the component's cell constraints * @throws NullPointerException if <code>constraints</code> is <code>null</code> * @throws IllegalArgumentException if <code>constraints</code> is not a * <code>CellConstraints</code> or a String that cannot be used to construct * a <code>CellConstraints</code> */ public void addLayoutComponent(Component comp, Object constraints) { if (constraints instanceof String) { setConstraints(comp, new CellConstraints((String) constraints)); } else if (constraints instanceof CellConstraints) { setConstraints(comp, (CellConstraints) constraints); } else if (constraints == null) { throw new NullPointerException("The constraints must not be null."); } else { throw new IllegalArgumentException("Illegal constraint type " + constraints.getClass()); } }
/** * Adds the specified component to the layout, using the specified * <code>constraints</code> object. Note that constraints are mutable and * are, therefore, cloned when cached. * * @param comp * the component to be added * @param constraints * the component's cell constraints * @throws NullPointerException * if <code>constraints</code> is <code>null</code> * @throws IllegalArgumentException * if <code>constraints</code> is not a * <code>CellConstraints</code> or a String that cannot be * used to construct a <code>CellConstraints</code> */ public void addLayoutComponent(Component comp, Object constraints) { if (constraints instanceof String) { setConstraints(comp, new CellConstraints((String) constraints)); } else if (constraints instanceof CellConstraints) { setConstraints(comp, (CellConstraints) constraints); } else if (constraints == null) { throw new NullPointerException("The constraints must not be null."); } else { throw new IllegalArgumentException("Illegal constraint type " + constraints.getClass()); } }
/** * Adds the specified component to the layout, using the specified * {@code constraints} object. Note that constraints are mutable and * are, therefore, cloned when cached. * * @param comp the component to be added * @param constraints the component's cell constraints * @throws NullPointerException if {@code constraints} is {@code null} * @throws IllegalArgumentException if {@code constraints} is neither * a String, nor a CellConstraints object, * or a String that is rejected by the CellConstraints construction */ @Override public void addLayoutComponent(Component comp, Object constraints) { checkNotNull(constraints, "The constraints must not be null."); if (constraints instanceof String) { setConstraints(comp, new CellConstraints((String) constraints)); } else if (constraints instanceof CellConstraints) { setConstraints(comp, (CellConstraints) constraints); } else { throw new IllegalArgumentException("Illegal constraint type " + constraints.getClass()); } }
/** * Sets the constraints for the given component. Note that you should not * change the column and row assignments using this method. * * @param gc * the grid component * @param cc * the cell constraints to set. */ public void setConstraints(GridComponent gc, CellConstraints cc) { m_formlayout.setConstraints(gc, cc); syncCellAssignments(); m_form.revalidate(); fireGridEvent(new GridViewEvent(this, GridViewEvent.CELL_CHANGED, gc)); }
layout.setConstraints(name, new CellConstraints(4, 1, alignment, CellConstraints.CENTER)); if (alignment == CellConstraints.RIGHT) { name.setHorizontalTextPosition(SwingConstants.LEFT);