public Dimension getPreferredSize() { int w = 0; int h = 0; Graphics g = PropUtils.getScratchGraphics(this); FontMetrics fm = g.getFontMetrics(getFont()); if (getIcon() != null) { w = getIcon().getIconWidth(); h = getIcon().getIconHeight(); } if (getBorder() != null) { Insets ins = getBorder().getBorderInsets(this); w+=ins.left + ins.right; h+=ins.bottom+ins.top; } w += fm.stringWidth(getText()) + 22; h = Math.max(fm.getHeight(), h) + 2; return new Dimension(w,h); } }
public Dimension getPreferredSize() { int w = 0; int h = 0; Graphics g = PropUtils.getScratchGraphics(this); FontMetrics fm = g.getFontMetrics(getFont()); if (getIcon() != null) { w = getIcon().getIconWidth(); h = getIcon().getIconHeight(); } if (getBorder() != null) { Insets ins = getBorder().getBorderInsets(this); w += (ins.left + ins.right); h += (ins.bottom + ins.top); } w += (fm.stringWidth(getText()) + 22); h = Math.max(fm.getHeight(), h) + 2; return new Dimension(w, h); } }
public Dimension getPreferredSize() { int w = 0; int h = 0; Graphics g = PropUtils.getScratchGraphics(this); FontMetrics fm = g.getFontMetrics(getFont()); if (getIcon() != null) { w = getIcon().getIconWidth(); h = getIcon().getIconHeight(); } if (getBorder() != null) { Insets ins = getBorder().getBorderInsets(this); w+=ins.left + ins.right; h+=ins.bottom+ins.top; } w += fm.stringWidth(getText()) + 22; h = Math.max(fm.getHeight(), h) + 2; return new Dimension(w,h); } }