Rectangle titleRect = new Rectangle(x + titleLeftInset - 1,
y - stringHeight + titleTopInset - TEXT_SPACING,
stringWidth + TEXT_SPACING,
stringHeight + 2*TEXT_SPACING);
if (titleRect.intersects(g.getClipBounds())) {
Rectangle[] difference = SwingUtilities.computeDifference(g.getClipBounds(), titleRect);
MultiRectArea clipArea = new MultiRectArea(difference);
g.setClip(clipArea);
}
}