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 |
/** |
/** |
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 |
|
|
913 |
if (getSelectedIndex() == -1) |
if (getSelectedIndex() == -1) |
914 |
setSelectedIndex(0); |
setSelectedIndex(0); |
915 |
|
|
916 |
layout(); |
revalidate(); |
917 |
repaint(); |
repaint(); |
918 |
} |
} |
919 |
|
|
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 |
|
|
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 |
|
|