Java Swing JTabbedPane删除白色边框

Java Swing JTabbedPane删除白色边框,java,swing,jtabbedpane,Java,Swing,Jtabbedpane,如何删除给定图片中的白线 白线: 我使用Swing并为选项卡窗格编写了自定义UI。 我试过: tabbedPane.setBorder(BorderFactory.createLineBorder(Color.black,1)); 但这不起作用 我也阅读了的文档,但在那里找不到更多的帮助 我的自定义用户界面: public class CustomTabbedPaneUI extends BasicTabbedPaneUI { private int inclTab = 4; private

如何删除给定图片中的白线

白线:

我使用Swing并为选项卡窗格编写了自定义UI。 我试过: tabbedPane.setBorder(BorderFactory.createLineBorder(Color.black,1)); 但这不起作用

我也阅读了的文档,但在那里找不到更多的帮助

我的自定义用户界面:

public class CustomTabbedPaneUI extends BasicTabbedPaneUI {

private int inclTab = 4;
private int anchoFocoV = inclTab;
private int anchoFocoH = 4;
private int anchoCarpetas = 18;
private Polygon shape;

public static ComponentUI createUI(JComponent c) {
    return new CustomTabbedPaneUI();
}

@Override
protected void installDefaults() {
    super.installDefaults();
    tabAreaInsets.right = anchoCarpetas;
}

@Override
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) {
    super.paintTabArea(g, tabPlacement, selectedIndex);
}

@Override
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
    Graphics2D g2D = (Graphics2D) g;
    int xp[] = null;
    int yp[] = null;
    
    xp = new int[] {x, x, x + w, x + w, x};
    yp = new int[] {y, y + h - 1, y + h - 1, y, y};
    shape = new Polygon(xp, yp, xp.length);
    g2D.setColor(Color.BLACK);
    g2D.setPaint(Color.BLACK);
    g2D.fill(shape);
}

@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
    super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
    int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
    g.setColor(Color.WHITE);
    BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
}

@Override
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
    return 20 + inclTab + super.calculateTabWidth(tabPlacement, tabIndex, metrics);
}

@Override
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
    if (tabPlacement == LEFT || tabPlacement == RIGHT) {
        return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight);
    } else {
        return anchoFocoH + super.calculateTabHeight(tabPlacement, tabIndex, fontHeight);
    }
}

@Override
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
    
}

@Override
protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) {
    if (tabPane.hasFocus() && isSelected) {
        g.setColor(Color.DARK_GRAY);
        g.drawPolygon(shape);
    }
}

protected void paintContendBorder(Graphics g, int tabPlacement, int selectedIndex) {
    super.paintContentBorder(g, tabPlacement, selectedIndex);
}
}

当需要更多信息时,请告诉我。

标准API有问题吗?如果是这样,请使用标准JDK类演示问题。如果没有,则返回到让自定义API实现默认绘制逻辑。然后一次修改一个方法。当代码停止工作时,您知道问题所在。