Code example for JLabel

Methods: getPreferredSize

0
   * 
   * @param width the new preferred width. 
   */ 
  public void setLabelWidth(final int width)
  { 
    final Dimension prefSize = entryLabel.getPreferredSize();
    entryLabelCarrier.setPreferredSize(new Dimension(width, prefSize.height));
  } 
 
  /** 
   * Returns the preferred width of the label. 
   * 
   * @return the preferred width. 
   */ 
  public int getLabelWidth() 
  { 
    final Dimension prefSize = entryLabel.getPreferredSize();
    if (prefSize != null)
    { 
      return prefSize.width;