import javax.swing.*; import java.awt.*; public class SetColorTab{ JFrame frame; JTabbedPane tpane; JPanel panel; public static void main(String[] args) { SetColorTab c = new SetColorTab(); } public SetColorTab(){ frame = new JFrame("Setting the Color of a Tab in a JTabbedPane Container"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tpane = new JTabbedPane(); panel = new JPanel(); tpane.addTab("Color", null, panel); panel = new JPanel(); tpane.addTab("Hardware", null, panel); panel = new JPanel(); tpane.addTab("Software", null, panel); panel = new JPanel(); tpane.addTab("Network", null, panel); tpane.setForegroundAt(2, Color.RED); tpane.setBackgroundAt(2, Color.GRAY); tpane.setForegroundAt(1, Color.PINK); tpane.setBackgroundAt(1, Color.GREEN); frame.add(tpane); frame.setSize(400,400); frame.setVisible(true); } }