private static int getLabelBaselineResizeBehavior(JLabel label) { if (label.getClientProperty("html") != null) { return BRB_OTHER; } switch (label.getVerticalAlignment()) { case JLabel.TOP: return BRB_CONSTANT_ASCENT; case JLabel.BOTTOM: return BRB_CONSTANT_DESCENT; case JLabel.CENTER: return BRB_CENTER_OFFSET; } return BRB_OTHER; }
private static int getLabelBaseline(JLabel label, int height) { Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon(); FontMetrics fm = label.getFontMetrics(label.getFont()); resetRects(label, height); SwingUtilities.layoutCompoundLabel( label, fm, "a", icon, label.getVerticalAlignment(), label.getHorizontalAlignment(), label.getVerticalTextPosition(), label.getHorizontalTextPosition(), viewRect, iconRect, textRect, label.getIconTextGap()); return textRect.y + fm.getAscent(); }