@Override
public int getPreferredWidth(int height) {
int preferredWidth = 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) {
int heightUpdated = height;
if (heightUpdated != -1) {
heightUpdated = Math.max(heightUpdated - (topThickness + thickness) -
padding.top - padding.bottom, 0);