title: Change JTabbedPane component on select tab
body: <p>I've got a JTabbedPane and i need to substitute tab 1 component when user select it.
  I can't directly add the right component at application start because i don't have full data to generate it.</p>
  
  <p>I need something like this:</p>
  
  <pre><code>    int tabTochange = 1;
      tabbedPane.addChangeListener(new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
              if (tabbedPane.getSelectedIndex() == tabTochange)
              {
                  JComponent component = generataComponent();
                  tabbedPane.removeTabAt(tabTochange); // Remove old tab
                  // add new one
                  tabbedPane.insertTab("title", null, component, "tip", tabTochange);
  
              }
          }
      });
  </code></pre>
  
  <p>But this code doesn't work, it removes the tab other tabs after tab 1 and duplicate it.</p>