@Override
public Dimensions getPreferredSize() {
int preferredWidth = 0;
int preferredHeight = 0;
Border border = (Border)getComponent();
int topThickness = thickness;
String title = border.getTitle();
if (title != null
&& title.length() > 0) {
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
Rectangle2D headingBounds = font.getStringBounds(title, fontRenderContext);
preferredWidth = (int)Math.ceil(headingBounds.getWidth());
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
Component content = border.getContent();
if (content != null) {
Dimensions preferredSize = content.getPreferredSize();
preferredWidth = Math.max(preferredWidth, preferredSize.width);
preferredHeight += preferredSize.height;
}