コード例 #1
0
 /**
  * Overridden to insert the tab at the end or requests focus on the added component.
  *
  * @see JTabbedPane#insertTab(String, Icon, Component, String, int)
  */
 public void insertTab(String title, Icon icon, Component component, String tip, int index) {
   int addIndex = indexOfComponent(component);
   if (addIndex != -1) {
     setSelectedComponent(component);
     return;
   }
   super.insertTab(title, icon, component, tip, getTabCount());
   ((ClosableTabbedPaneUI) ui).resetDefault();
 }
コード例 #2
0
  /**
   * Overridden to fire a property change indicating that component is removed from the tab pane.
   *
   * @see JTabbedPane#removeTabAt(int)
   */
  public void removeTabAt(int index) {
    Component c = getComponentAt(index);
    if (c instanceof ClosableTabbedPaneComponent) {
      firePropertyChange(CLOSE_TAB_PROPERTY, null, c);
    }
    super.removeTabAt(index);
    ((ClosableTabbedPaneUI) ui).resetDefault();
    int n = getTabCount();
    if (n == 0) return;

    if (index > n) setSelectedComponent(getComponentAt(n - 1));
  }