示例#1
0
  @Override
  public void insertTab(String title, Icon icon, Component component, String tip, int index) {
    TabComponent tabComp;

    if (component instanceof ExternalizablePanel) {
      final ExternalizablePanel panel = (ExternalizablePanel) component;
      tabComp = getTabComponent(panel);

      // not existing ?
      if (tabComp == null) {
        // create the associated tab component
        tabComp = new TabComponent(title, icon, panel, tip, index);
        // and save it in the list to keep a reference
        tabComponents.add(tabComp);
      }

      // externalized ?
      if (panel.isExternalized()) {
        // manually set parent and exit
        panel.setParent(this);
        return;
      }
    } else tabComp = null;

    super.insertTab(title, icon, component, tip, index);

    // use custom panel for externalizable panel
    if (tabComp != null) setTabComponentAt(index, tabComp);
  }
 @Override
 public void removeListener(Object source) {
   if (source != null) ((ExternalizablePanel) source).removeStateListener(this);
 }