e837. 设置JTabbedPane中卡片的颜色

 // Create a tabbed pane
    JTabbedPane pane = new JTabbedPane();
    
    // Set the text color for all tabs
    pane.setForeground(Color.YELLOW);
    
    // Set the background color for all tabs
    pane.setBackground(Color.MAGENTA);
    
    // Add a tab
    String label = "Tab Label";
    pane.addTab(label, component);
    
    // Get index of the new tab
    int index = pane.getTabCount()-1;
    
    // Set text color for the new tab
    pane.setForegroundAt(index, Color.ORANGE);
    
    // Set background color for the new tab
    pane.setBackgroundAt(index, Color.GREEN);

 

Related Examples
posted @ 2018-09-06 09:17  borter  阅读(277)  评论(0编辑  收藏  举报