Dimension dimension = getSize();
g.setClip(0, 0, dimension.width, dimension.height);
FontMetrics fontmetrics = null;
g.setColor(getBackground());
g.fillRect(0, 0, dimension.width + 1, dimension.height + 1);
g.setColor(getForeground());
g.setFont(getFont());
fontmetrics = Toolkit.getDefaultToolkit().getFontMetrics(getFont());
int i = (dimension.height - (fontmetrics.getMaxAscent() + fontmetrics.getMaxDescent())) / 2 + fontmetrics.getMaxAscent();
g.drawString(headerText, fontmetrics.stringWidth(""), i);
int j = dimension.height - fontmetrics.getMaxDescent() / 2;
g.drawLine(0, j, dimension.width, j);