public void paintComponent(Graphics g) {
        if (isPalette) {
            paintPalette(g);
            return;
        }

        paintBackground(g);

        boolean leftToRight = JTattooUtilities.isLeftToRight(frame);

        int width = getWidth();
        int height = getHeight();
        int xOffset = leftToRight ? 5 : width - 5;
        int titleWidth = width - buttonsWidth - 10;

        Icon icon = frame.getFrameIcon();
        if (icon != null) {
            if (!isMacStyleWindowDecoration()) {
                if (!leftToRight) {
                    xOffset -= icon.getIconWidth();
                }
                int iconY = (height / 2) - (icon.getIconHeight() / 2) - 1;
                int iconWidth = paintIcon(g, xOffset, iconY);
                xOffset += leftToRight ? iconWidth + 5 : -5;
                titleWidth -= iconWidth + 5;
            } else {
                titleWidth -= icon.getIconWidth() + 5;
            }
        }

        g.setFont(getFont());
        FontMetrics fm = g.getFontMetrics();
        String frameTitle = JTattooUtilities.getClippedText(frame.getTitle(), fm, titleWidth);
        int titleLength = fm.stringWidth(frameTitle);
        int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();
        if (!leftToRight) {
            xOffset -= titleLength;
        }
        if (AbstractLookAndFeel.getTheme().isMacStyleWindowDecorationOn()) {
            xOffset = Math.max(buttonsWidth + 5, (width - titleLength) / 2);
        }
        paintText(g, xOffset, yOffset, frameTitle);
        paintBorder(g);
    }