package javax.swing;
+import gnu.classpath.NotImplementedException;
+
import java.awt.Color;
import java.awt.Component;
import java.awt.Point;
* @param e the change event describing the change
*/
public void stateChanged(ChangeEvent e)
+ throws NotImplementedException
{
// Implement this properly.
}
* @return the accessible role of the <code>JTabbedPane</code>
*/
public AccessibleRole getAccessibleRole()
+ throws NotImplementedException
{
return null;
}
* <code>JTabbedPane</code>
*/
public int getAccessibleChildrenCount()
+ throws NotImplementedException
{
return 0;
}
* @return the current selection state of the <code>JTabbedPane</code>
*/
public AccessibleSelection getAccessibleSelection()
+ throws NotImplementedException
{
return null;
}
* this location
*/
public Accessible getAccessibleAt(Point p)
+ throws NotImplementedException
{
return null;
}
* <code>JTabbedPane</code>
*/
public int getAccessibleSelectionCount()
+ throws NotImplementedException
{
return 0;
}
* @return DOCUMENT ME!
*/
public Accessible getAccessibleSelection(int i)
+ throws NotImplementedException
{
return null;
}
* @return DOCUMENT ME!
*/
public boolean isAccessibleChildSelected(int i)
+ throws NotImplementedException
{
return false;
}
* @param i DOCUMENT ME!
*/
public void addAccessibleSelection(int i)
+ throws NotImplementedException
{
// TODO: Implement this properly.
}
* @param i DOCUMENT ME!
*/
public void removeAccessibleSelection(int i)
+ throws NotImplementedException
{
// TODO: Implement this properly.
}
* DOCUMENT ME!
*/
public void clearAccessibleSelection()
+ throws NotImplementedException
{
// TODO: Implement this properly.
}
* DOCUMENT ME!
*/
public void selectAllAccessibleSelection()
+ throws NotImplementedException
{
// TODO: Implement this properly.
}
*/
public Color getBackground()
{
- return bg;
+ Color background;
+ if (bg == null)
+ background = JTabbedPane.this.getBackground();
+ else
+ background = bg;
+ return background;
}
/**
*/
public Color getForeground()
{
- return fg;
+ Color foreground;
+ if (fg == null)
+ foreground = JTabbedPane.this.getForeground();
+ else
+ foreground = fg;
+ return foreground;
}
/**
}
public AccessibleStateSet getAccessibleStateSet()
+ throws NotImplementedException
{
// FIXME: Implement this properly.
return null;
}
public int getAccessibleIndexInParent()
+ throws NotImplementedException
{
// FIXME: Implement this properly.
return 0;
public void updateUI()
{
setUI((TabbedPaneUI) UIManager.getUI(this));
- invalidate();
}
/**
*/
public Component getSelectedComponent()
{
- return getComponentAt(getSelectedIndex());
+ int selectedIndex = getSelectedIndex();
+ Component selected = null;
+ if (selectedIndex >= 0)
+ selected = getComponentAt(selectedIndex);
+ return selected;
}
/**
public void removeTabAt(int index)
{
checkIndex(index, 0, tabs.size());
+
+ // We need to adjust the selection if we remove a tab that comes
+ // before the selected tab or if the selected tab is removed.
+ // This decrements the selected index by 1 if any of this is the case.
+ // Note that this covers all cases:
+ // - When the selected tab comes after the removed tab, this simply
+ // adjusts the selection so that after the removal the selected tab
+ // is still the same.
+ // - When we remove the currently selected tab, then the tab before the
+ // selected tab gets selected.
+ // - When the last tab is removed, then we have an index==0, which gets
+ // decremented to -1, which means no selection, which is 100% perfect.
+ int selectedIndex = getSelectedIndex();
+ if (selectedIndex >= index)
+ setSelectedIndex(selectedIndex - 1);
+
+ Component comp = getComponentAt(index);
+
+ // Remove the tab object.
tabs.remove(index);
- getComponentAt(index).show();
+
+ // Remove the component. I think we cannot assume that the tab order
+ // is equal to the component order, so we iterate over the children
+ // here to find the and remove the correct component.
+ if (comp != null)
+ {
+ Component[] children = getComponents();
+ for (int i = children.length - 1; i >= 0; --i)
+ {
+ if (children[i] == comp)
+ {
+ super.remove(i);
+ comp.setVisible(true);
+ break;
+ }
+ }
+ }
+ revalidate();
+ repaint();
}
/**
*/
public void removeAll()
{
- for (int i = tabs.size() - 1; i >= 0; i--)
+ setSelectedIndex(-1);
+ for (int i = getTabCount() - 1; i >= 0; i--)
removeTabAt(i);
}