protected void paintTopTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected) {
        int tc = tabPane.getTabCount();
        int currentRun = getRunForTab(tc, tabIndex);
        int lastIndex = lastTabInRun(tc, currentRun);
        int firstIndex = tabRuns[currentRun];
        boolean leftToRight = JTattooUtilities.isLeftToRight(tabPane);

        Color loColor = getLoBorderColor(tabIndex);
        Color hiColor = getHiBorderColor(tabIndex);

        g.setColor(loColor);
        g.drawLine(x1 + GAP, y1, x2, y1);
        g.drawLine(x1 + GAP, y1, x1, y1 + GAP);
        g.drawLine(x1, y1 + GAP + 1, x1, y2);
        g.drawLine(x2, y1, x2, y2);
        g.setColor(hiColor);
        g.drawLine(x1 + GAP + 1, y1 + 1, x2 - 1, y1 + 1);
        g.drawLine(x1 + GAP + 1, y1 + 1, x1 + 1, y1 + GAP + 1);
        g.drawLine(x1 + 1, y1 + GAP + 1, x1 + 1, y2 - 1);

        // paint gap
        int gapTabIndex = getTabAtLocation(x1 + 2, y1 - 2);
        Color gapColor = getGapColor(gapTabIndex);
        g.setColor(gapColor);
        for (int i = 0; i < GAP; i++) {
            g.drawLine(x1, y1 + i, x1 + GAP - i - 1, y1 + i);
        }

        if (leftToRight) {
            if ((tabIndex != firstIndex) || (currentRun != (runCount - 1))) {
                g.setColor(loColor);
                g.drawLine(x1, y1, x1, y1 + GAP);
            }
            if (!isSelected && (tabIndex == firstIndex) && (currentRun != (runCount - 1))) {
                g.setColor(hiColor);
                g.drawLine(x1 + 1, y1, x1 + 1, y1 + GAP - 2);
            }
        } else {
            if ((tabIndex != lastIndex) || (currentRun != (runCount - 1))) {
                g.setColor(loColor);
                g.drawLine(x1, y1, x1, y1 + GAP);
            }
        }
    }