/** * Returns an enum indicating how the baseline of the border * changes as the size changes. * * @throws NullPointerException {@inheritDoc} * @see javax.swing.JComponent#getBaseline(int, int) * @since 1.6 */ public Component.BaselineResizeBehavior getBaselineResizeBehavior( Component c) { super.getBaselineResizeBehavior(c); switch (getPosition()) { case JideTitledBorder.ABOVE_TOP: case JideTitledBorder.TOP: case JideTitledBorder.BELOW_TOP: return Component.BaselineResizeBehavior.CONSTANT_ASCENT; case JideTitledBorder.ABOVE_BOTTOM: case JideTitledBorder.BOTTOM: case JideTitledBorder.BELOW_BOTTOM: return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT; } return Component.BaselineResizeBehavior.OTHER; }
/** * Returns the minimum dimensions this border requires in order to fully display the border and title. * * @param c the component where this border will be drawn */ public Dimension getMinimumSize(Component c) { Insets insets = getBorderInsets(c); Dimension minSize = new Dimension(insets.right + insets.left, insets.top + insets.bottom); String title = getTitle(); if ((title != null) && !title.isEmpty()) { JLabel label = getLabel(c); Dimension size = label.getPreferredSize(); int position = getPosition(); if ((position != ABOVE_TOP) && (position != BELOW_BOTTOM)) { minSize.width += size.width; } else if (minSize.width < size.width) { minSize.width += size.width; } } return minSize; }
switch (getPosition()) { case ABOVE_TOP: return baseline;
int position = getPosition(); switch (position) { case ABOVE_TOP:
Dimension size = label.getPreferredSize(); switch (getPosition()) { case ABOVE_TOP: insets.top += size.height - edge;