Border border = (Border)getComponent();
int topThickness = thickness;
// Delegate baseline calculation to the content component
Component content = border.getContent();
if (content != null) {
String title = border.getTitle();
if (title != null
&& title.length() > 0) {
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
int clientWidth = Math.max(width - (thickness * 2)
- (padding.left + padding.right), 0);
int clientHeight = Math.max(height - (topThickness + thickness) -
(padding.top + padding.bottom), 0);
baseline = content.getBaseline(clientWidth, clientHeight);
}
// Include top padding value and top border thickness
if (baseline != -1) {
baseline += (padding.top + topThickness);