/[classpath]/classpath/javax/swing/JTabbedPane.java
ViewVC logotype

Diff of /classpath/javax/swing/JTabbedPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11.2.8 by gnu_andrew, Wed Nov 2 00:43:47 2005 UTC revision 1.11.2.9 by gnu_andrew, Sun Nov 27 21:00:37 2005 UTC
# Line 337  public class JTabbedPane extends JCompon Line 337  public class JTabbedPane extends JCompon
337       */       */
338      public void setComponent(Component c)      public void setComponent(Component c)
339      {      {
340        remove(component);        int i = indexOfComponent(component);
341        this.component = c;        insertTab(title, icon, c, tip, i);
342        add(c);        component = c;
343          removeTabAt(i);
344      }      }
345    
346      /**      /**
# Line 620  public class JTabbedPane extends JCompon Line 621  public class JTabbedPane extends JCompon
621        throw new IllegalArgumentException("tabLayoutPolicy is not valid.");        throw new IllegalArgumentException("tabLayoutPolicy is not valid.");
622      this.tabPlacement = tabPlacement;      this.tabPlacement = tabPlacement;
623      layoutPolicy = tabLayoutPolicy;      layoutPolicy = tabLayoutPolicy;
624        
625      changeEvent = new ChangeEvent(this);      changeEvent = new ChangeEvent(this);
626      changeListener = createChangeListener();      changeListener = createChangeListener();
627    
# Line 912  public class JTabbedPane extends JCompon Line 913  public class JTabbedPane extends JCompon
913      if (getSelectedIndex() == -1)      if (getSelectedIndex() == -1)
914        setSelectedIndex(0);        setSelectedIndex(0);
915    
916      layout();      revalidate();
917      repaint();      repaint();
918    }    }
919    
# Line 968  public class JTabbedPane extends JCompon Line 969  public class JTabbedPane extends JCompon
969        super.add(component);        super.add(component);
970      else      else
971        insertTab(component.getName(), null, component, null, tabs.size());        insertTab(component.getName(), null, component, null, tabs.size());
972        
973      return component;      return component;
974    }    }
975    
# Line 1051  public class JTabbedPane extends JCompon Line 1053  public class JTabbedPane extends JCompon
1053    }    }
1054    
1055    /**    /**
1056     * The tab and it's associated component are removed. After the component     * Removes the tab at index. After the component associated with
1057     * has been removed from the JTabbedPane, it's set visible to ensure that     * index is removed, its visibility is reset to true to ensure it
1058     * it can be seen.     * will be visible if added to other containers.
1059     *     *
1060     * @param index The index of the tab to remove.     * @param index The index of the tab to remove.
1061     */     */
1062    public void removeTabAt(int index)    public void removeTabAt(int index)
1063    {    {
1064      checkIndex(index, 0, tabs.size());      checkIndex(index, 0, tabs.size());
     Component c = getComponentAt(index);  
     super.remove(index);  
     c.show();  
1065      tabs.remove(index);      tabs.remove(index);
1066        getComponentAt(index).show();
1067    }    }
1068    
1069    /**    /**
1070     * This method removes the component from the JTabbedPane. After the     * Removes the specified Component from the JTabbedPane.
    * component has been removed from the JTabbedPane, it's  set visible to  
    * ensure that it can be seen.  
1071     *     *
1072     * @param component The Component to remove.     * @param component The Component to remove.
1073     */     */
1074    public void remove(Component component)    public void remove(Component component)
1075    {    {
     // This simply removes the component.  
     int index = indexOfComponent(component);  
1076      super.remove(component);      super.remove(component);
     component.show();  
     setComponentAt(index, null);  
1077    }    }
1078    
1079    /**    /**
1080     * This method removes the tab and component from the JTabbedPane. It simply     * Removes the tab and component which corresponds to the specified index.
    * calls removeTabAt(int index).  
1081     *     *
1082     * @param index The index of the tab to remove.     * @param index The index of the tab to remove.
1083     */     */
1084    public void remove(int index)    public void remove(int index)
1085    {    {
1086        remove(getComponentAt(index));
1087      removeTabAt(index);      removeTabAt(index);
1088    }    }
1089    

Legend:
Removed from v.1.11.2.8  
changed lines
  Added in v.1.11.2.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26