How to change background color of JTabbedPane?

Using TabComponentsDemo as an example, setBackgroundAt() seems to work: private void initTabComponent(int i) { pane.setTabComponentAt(i, new ButtonTabComponent(pane)); pane.setBackgroundAt(i, Color.getHSBColor((float)i/tabNumber, 1, 1)); } Addendum: As @camickr helpfully observed, the target component must be opaque. import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; /** @see http://stackoverflow.com/questions/8752037 */ public class TabColors extends … Read more

Java: JProgressBar (or equivalent) in a JTabbedPane tab title

For earlier versions, you might try addTab() with a suitable implementation of Icon used to indicate progress. import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; public class JTabbedTest { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { private final JTabbedPane jtp = new JTabbedPane(); public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); … Read more

How can I change the shape of a JTabbedPane tab?

correct way is only to change Look and Feel, nice example from Old.Java.Forums.Sun import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextArea; public class TabbedPane extends JPanel { private static final long serialVersionUID = 1L; public TabbedPane() { setLayout(new BorderLayout()); JPanel jp = new JPanel(); jp.setLayout(new BorderLayout()); JTabbedPane tb = new JTabbedPane(); tb.setUI(new CustomTabbedPaneUI()); … Read more

tech