Rectangle 27 0

java JTabbedPane: new Tab in different color till first time opened?

public TabColors() {
    for (int i = 0; i < MAX; i++) {
        Color color = Color.lightGray;
        pane.add("Tab " + String.valueOf(i), new TabContent(i, color));
        pane.setBackgroundAt(i, color);
    pane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {

It is an JTabbedPane with scrollable Textareas. The tabs have got JPanels with the name of the tab and a close Button

Starting from this example, the following changes produce the effects illustrated below. Each tab starts as Color.lightGray, and a ChangeListener changes the background color to the first time each tab is selected. You can so something similar in a listener to your application's data model; several approaches are examined here.

Starting from this example, yes. Depending on your application's data model, you may want to use a different listener.

What is pane? Is it a JTabbedPane? Because I cant use a ChangeListener for a JTabbedPane