This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui][PATCH]: fyi - Implement JTabbedPane and BasicArrowButton


Hi,

This implements JTabbedPane and BasicArrowButton. Also many fixes.

Cheers,

Kim

2004-03-23  Kim Ho  <kho@redhat.com>

	* Makefile.am: New file
	* Makefile.in: Regenerate
	* java/awt/Graphics.java: (drawRect):
	Draw to the correct point.
	* javax/swing/DefaultSingleSelectionModel.java
	(isSelected): Return true if the selected index
	is not -1.
	* javax/swing/JLabel.java: Do not change mnemonic
	index if text is null.
	* javax/swing/JProgressBar.java: Use JComponent's
	EventListenerList.
	* javax/swing/JScrollBar.java: Ditto.
	* javax/swing/JTabbedPane.java: Reimplement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Add defaults for TabbedPane.
	* javax/swing/plaf/basic/BasicArrowButton.java:
	Implement
	* javax/swing/plaf/basic/BasicProgressBarUI.java:
	(paintDeterminate): Don't paint String if it's
	empty.
	(paintIndeterminate): ditto.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
	Reimplement.
	
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.361.2.6
diff -u -r1.361.2.6 Makefile.am
--- Makefile.am	4 Mar 2004 17:31:02 -0000	1.361.2.6
+++ Makefile.am	23 Mar 2004 14:27:44 -0000
@@ -1244,6 +1244,7 @@
 javax/swing/GrayFilter.java \
 javax/swing/AbstractAction.java \
 javax/swing/AbstractButton.java \
+javax/swing/plaf/basic/BasicArrowButton.java \
 javax/swing/plaf/basic/BasicButtonListener.java \
 javax/swing/plaf/basic/BasicButtonUI.java \
 javax/swing/plaf/basic/BasicCheckBoxUI.java \
Index: java/awt/Graphics.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Graphics.java,v
retrieving revision 1.6
diff -u -r1.6 Graphics.java
--- java/awt/Graphics.java	11 Jun 2003 10:37:47 -0000	1.6
+++ java/awt/Graphics.java	23 Mar 2004 14:27:46 -0000
@@ -417,7 +417,7 @@
   drawLine(x1, y2, x1, y1);
   setColor(br);
   drawLine(x2, y1, x2, y2);
-  drawLine(x2, y1, x1, y2);
+  drawLine(x2, y2, x1, y2);
   setColor(color);
 }
 
Index: javax/swing/DefaultSingleSelectionModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/DefaultSingleSelectionModel.java,v
retrieving revision 1.4
diff -u -r1.4 DefaultSingleSelectionModel.java
--- javax/swing/DefaultSingleSelectionModel.java	29 Apr 2003 09:26:29 -0000	1.4
+++ javax/swing/DefaultSingleSelectionModel.java	23 Mar 2004 14:27:46 -0000
@@ -115,7 +115,7 @@
    */
   public boolean isSelected ()
   {
-    return (index == -1);
+    return (index != -1);
   }
 
   /**
Index: javax/swing/JLabel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JLabel.java,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 JLabel.java
--- javax/swing/JLabel.java	18 Feb 2004 14:43:42 -0000	1.4.2.3
+++ javax/swing/JLabel.java	23 Mar 2004 14:27:46 -0000
@@ -289,7 +289,7 @@
 	String oldText = labelText;
 	labelText = text;
 	firePropertyChange(TEXT_CHANGED_PROPERTY, oldText, labelText);
-	if (labelText.length() <= underlinedChar)
+	if (labelText != null && labelText.length() <= underlinedChar)
 	  setDisplayedMnemonicIndex(labelText.length() - 1);
       }
   }
Index: javax/swing/JProgressBar.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JProgressBar.java,v
retrieving revision 1.3.8.3
diff -u -r1.3.8.3 JProgressBar.java
--- javax/swing/JProgressBar.java	9 Mar 2004 16:38:14 -0000	1.3.8.3
+++ javax/swing/JProgressBar.java	23 Mar 2004 14:27:46 -0000
@@ -185,9 +185,6 @@
   /** Fired in a PropertyChangeEvent when the "indeterminate" property changes. */
   public static final String INDETERMINATE_CHANGED_PROPERTY = "indeterminate";
 
-  /** A list of ChangeListeners registered with this ProgressBar. */
-  private transient EventListenerList changeListenerList;
-
   /** Whether the ProgressBar is determinate. */
   private transient boolean indeterminate = false;
 
@@ -260,7 +257,6 @@
     this.orientation = orientation;
     changeListener = createChangeListener();
     model.addChangeListener(changeListener);
-    changeListenerList = new EventListenerList();
     updateUI();
   }
 
@@ -275,7 +271,6 @@
     this.model = model;
     changeListener = createChangeListener();
     model.addChangeListener(changeListener);
-    changeListenerList = new EventListenerList();
     updateUI();    
   }
 
@@ -511,7 +506,7 @@
    */
   public void addChangeListener(ChangeListener listener)
   {
-    changeListenerList.add(ChangeListener.class, listener);
+    listenerList.add(ChangeListener.class, listener);
   }
 
   /**
@@ -521,7 +516,7 @@
    */
   public void removeChangeListener(ChangeListener listener)
   {
-    changeListenerList.remove(ChangeListener.class, listener);
+    listenerList.remove(ChangeListener.class, listener);
   }
   
   /**
@@ -532,7 +527,7 @@
    */
   public ChangeListener[] getChangeListeners()
   {
-    return (ChangeListener[]) changeListenerList.getListenerList();
+    return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
   }  
 
   /**
@@ -542,7 +537,7 @@
    */
   protected void fireStateChanged()
   {
-    Object[] changeListeners = changeListenerList.getListenerList();
+    Object[] changeListeners = listenerList.getListenerList();
     if (changeEvent == null)
       changeEvent = new ChangeEvent(this);
     for (int i = changeListeners.length - 2; i >= 0; i -= 2)
Index: javax/swing/JScrollBar.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JScrollBar.java,v
retrieving revision 1.2.18.1
diff -u -r1.2.18.1 JScrollBar.java
--- javax/swing/JScrollBar.java	26 Feb 2004 14:24:08 -0000	1.2.18.1
+++ javax/swing/JScrollBar.java	23 Mar 2004 14:27:48 -0000
@@ -176,12 +176,6 @@
   /** How much the thumb moves when moving in a unit. */
   protected int unitIncrement = 1;
 
-  /** A list of all ChangeListeners attached to the scroll bar. */
-  private transient EventListenerList changeListenerList;
-
-  /** A list of all AdjustmentListeners attached to the scroll bar. */
-  private transient EventListenerList adjustmentListenerList;
-
   /** The ChangeListener that listens to the model. */
   private transient ChangeListener changeListener;
 
@@ -228,8 +222,6 @@
                                          + " is not a legal orientation");
     this.orientation = orientation;
     changeListener = createChangeListener();
-    changeListenerList = new EventListenerList();
-    adjustmentListenerList = new EventListenerList();
     model.addChangeListener(changeListener);
     updateUI();
   }
@@ -586,7 +578,7 @@
    */
   private void fireStateChanged()
   {
-    Object[] changeListeners = changeListenerList.getListenerList();
+    Object[] changeListeners = listenerList.getListenerList();
     if (changeEvent == null)
       changeEvent = new ChangeEvent(this);
     for (int i = changeListeners.length - 2; i >= 0; i -= 2)
@@ -603,7 +595,7 @@
    */
   public void addChangeListener(ChangeListener listener)
   {
-    changeListenerList.add(ChangeListener.class, listener);
+    listenerList.add(ChangeListener.class, listener);
   }
 
   /**
@@ -613,7 +605,7 @@
    */
   public void removeChangeListener(ChangeListener listener)
   {
-    changeListenerList.remove(ChangeListener.class, listener);
+    listenerList.remove(ChangeListener.class, listener);
   }
 
   /**
@@ -624,7 +616,7 @@
    */
   public ChangeListener[] getChangeListeners()
   {
-    return (ChangeListener[]) changeListenerList.getListenerList();
+    return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
   }
 
   /**
@@ -634,7 +626,7 @@
    */
   public void addAdjustmentListener(AdjustmentListener listener)
   {
-    adjustmentListenerList.add(AdjustmentListener.class, listener);
+    listenerList.add(AdjustmentListener.class, listener);
   }
 
   /**
@@ -644,7 +636,7 @@
    */
   public void removeAdjustmentListener(AdjustmentListener listener)
   {
-    adjustmentListenerList.remove(AdjustmentListener.class, listener);
+    listenerList.remove(AdjustmentListener.class, listener);
   }
 
   /**
@@ -655,7 +647,7 @@
    */
   public AdjustmentListener[] getAdjustmentListeners()
   {
-    return (AdjustmentListener[]) adjustmentListenerList.getListenerList();
+    return (AdjustmentListener[]) listenerList.getListeners(AdjustmentListener.class);
   }
 
   /**
@@ -670,7 +662,7 @@
    */
   protected void fireAdjustmentValueChanged(int id, int type, int value)
   {
-    Object[] adjustmentListeners = adjustmentListenerList.getListenerList();
+    Object[] adjustmentListeners = listenerList.getListenerList();
     AdjustmentEvent adjustmentEvent = new AdjustmentEvent(this, 
                                             AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
 					    AdjustmentEvent.TRACK,
Index: javax/swing/JSlider.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JSlider.java,v
retrieving revision 1.3.18.5
diff -u -r1.3.18.5 JSlider.java
--- javax/swing/JSlider.java	26 Feb 2004 14:24:08 -0000	1.3.18.5
+++ javax/swing/JSlider.java	23 Mar 2004 14:27:48 -0000
@@ -253,9 +253,6 @@
    */
   private transient Dictionary labelTable;
 
-  /** A list of all ChangeListeners listening to this slider. */
-  private transient EventListenerList changeListenerList;
-
   /** The model used to describe the slider. */
   protected BoundedRangeModel sliderModel;
 
@@ -342,7 +339,6 @@
       throw new IllegalArgumentException(orientation + " is not a legal orientation");
     this.orientation = orientation;
     changeListener = createChangeListener();
-    changeListenerList = new EventListenerList();
     sliderModel.addChangeListener(changeListener);
     updateUI();
   }
@@ -359,7 +355,6 @@
     else
       sliderModel = model;
     changeListener = createChangeListener();
-    changeListenerList = new EventListenerList();
     sliderModel.addChangeListener(changeListener);
     updateUI();
   }
@@ -453,7 +448,7 @@
    */
   public void addChangeListener(ChangeListener listener)
   {
-    changeListenerList.add(ChangeListener.class, listener);
+    listenerList.add(ChangeListener.class, listener);
   }
 
   /**
@@ -463,7 +458,7 @@
    */
   public void removeChangeListener(ChangeListener listener)
   {
-    changeListenerList.remove(ChangeListener.class, listener);
+    listenerList.remove(ChangeListener.class, listener);
   }
 
   /**
@@ -473,7 +468,7 @@
    */
   protected void fireStateChanged()
   {
-    Object[] changeListeners = changeListenerList.getListenerList();
+    Object[] changeListeners = listenerList.getListenerList();
     if (changeEvent == null)
       changeEvent = new ChangeEvent(this);
     for (int i = changeListeners.length - 2; i >= 0; i -= 2)
@@ -491,7 +486,7 @@
    */
   public ChangeListener[] getChangeListeners()
   {
-    return (ChangeListener[]) changeListenerList.getListenerList();
+    return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
   }
 
   /**
Index: javax/swing/JTabbedPane.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JTabbedPane.java,v
retrieving revision 1.3
diff -u -r1.3 JTabbedPane.java
--- javax/swing/JTabbedPane.java	12 Feb 2004 00:17:23 -0000	1.3
+++ javax/swing/JTabbedPane.java	23 Mar 2004 14:27:48 -0000
@@ -1,5 +1,5 @@
-/* JTabbedPane.java -- 
-   Copyright (C) 2002 Free Software Foundation, Inc.
+/* JTabbedPane.java --
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,96 +35,1446 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
-
 package javax.swing;
 
+import java.awt.Color;
 import java.awt.Component;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.io.Serializable;
 import java.util.Vector;
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleStateSet;
+import javax.accessibility.AccessibleValue;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.event.EventListenerList;
 import javax.swing.plaf.TabbedPaneUI;
+import javax.swing.plaf.UIResource;
+
 
-public class JTabbedPane extends JComponent implements Accessible, SwingConstants
+/**
+ * <p>
+ * This is a container for components. One component is displayed at a time.
+ * Users can switch between components by clicking on tabs.
+ * </p>
+ * 
+ * <p>
+ * Tabs can be oriented in several ways. They can be above, below, left and
+ * right of the component. Tabs can either wrap around (by creating multiple
+ * rows of tabs) or they can be scrolled (where only a subset of the  tabs
+ * can be seen at once). More tabs can be added by calling the
+ * add/addTab/insertTab methods.
+ * </p>
+ */
+public class JTabbedPane extends JComponent implements Serializable,
+                                                       Accessible,
+                                                       SwingConstants
 {
-    class Tab
+  /**
+   * DOCUMENT ME!
+   */
+  protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent
+    implements AccessibleSelection, ChangeListener
+  {
+    /**
+     * Creates a new AccessibleJTabbedPane object.
+     *
+     * @param c DOCUMENT ME!
+     */
+    public AccessibleJTabbedPane(JTabbedPane c)
+    {
+      super(c);
+    }
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @param e DOCUMENT ME!
+     */
+    public void stateChanged(ChangeEvent e)
     {
-	Icon icon;
-	String name, descr;
-	Component tab;
+    }
 
-	Tab(String name,
-	    Icon icon,
-	    Component tab,
-	    String descr)
-	{
-	    this.name = name;
-	    this.icon = icon;
-	    this.tab  = tab;
-	    this.descr = descr;
-	}
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public AccessibleRole getAccessibleRole()
+    {
+      return null;
     }
-    
-    private Vector tabs = new Vector();
 
-    public JTabbedPane()
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public int getAccessibleChildrenCount()
     {
+      return 0;
     }
 
-    public void addTab(String name,
-		Component panel)		
+    /**
+     * DOCUMENT ME!
+     *
+     * @param i DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public Accessible getAccessibleChild(int i)
     {
-	addTab(name, null, panel, null);
+      return null;
     }
-    public void addTab(String name,
-		Icon icon,
-		Component panel)		
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public AccessibleSelection getAccessibleSelection()
     {
-	addTab(name, icon, panel, null);
+      return null;
     }
-    public void addTab(String name,
-		Icon icon,
-		Component panel,
-		String descr)
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @param p DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public Accessible getAccessibleAt(Point p)
     {
-	tabs.addElement(new Tab(name, icon, panel, descr));
+      return null;
     }
 
-    public int getTabCount()
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public int getAccessibleSelectionCount()
     {
-	return tabs.size();
+      return 0;
     }
-    public Component getComponentAt(int i)
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @param i DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public Accessible getAccessibleSelection(int i)
     {
-	Tab t = (Tab) tabs.elementAt(i);
-	return t.tab;
+      return null;
     }
-    
-    public String getUIClassID()
-    {	return "TabbedPaneUI";    }
 
+    /**
+     * DOCUMENT ME!
+     *
+     * @param i DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public boolean isAccessibleChildSelected(int i)
+    {
+      return false;
+    }
 
-    public void setUI(TabbedPaneUI ui) {
-        super.setUI(ui);
+    /**
+     * DOCUMENT ME!
+     *
+     * @param i DOCUMENT ME!
+     */
+    public void addAccessibleSelection(int i)
+    {
+    }
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @param i DOCUMENT ME!
+     */
+    public void removeAccessibleSelection(int i)
+    {
+    }
+
+    /**
+     * DOCUMENT ME!
+     */
+    public void clearAccessibleSelection()
+    {
+    }
+
+    /**
+     * DOCUMENT ME!
+     */
+    public void selectAllAccessibleSelection()
+    {
+    }
+  }
+
+  /**
+   * A helper class that listens for changes to the model.
+   */
+  protected class ModelListener implements ChangeListener, Serializable
+  {
+    /**
+     * This method is called whenever the model  is changed.
+     *
+     * @param e The ChangeEvent that is passed from the model.
+     */
+    public void stateChanged(ChangeEvent e)
+    {
+      // Propagate to our listeners.
+      fireStateChanged();
+    }
+  }
+
+  /**
+   * A private class that holds all the information  for each tab.
+   */
+  private class Page
+  {
+    /** The tooltip string. */
+    private String tip;
+
+    /** The component associated with the tab. */
+    private Component component;
+
+    /** The active icon associated with the tab. */
+    private transient Icon icon;
+
+    /** The disabled icon associated with the tab. */
+    private transient Icon disabledIcon;
+
+    /** The tab's enabled status. */
+    private transient boolean enabled = true;
+
+    /** The string painted on the tab. */
+    private transient String title;
+
+    /** The background color of the tab. */
+    private transient Color bg;
+
+    /** The foreground color of the tab. */
+    private transient Color fg;
+
+    /** The mnemonic associated with the tab. */
+    private transient int mnemonicKey;
+
+    /** The index of the underlined character in the string. */
+    private transient int underlinedChar = -1;
+
+    /**
+     * Creates a new data storage for the tab.
+     *
+     * @param title The string displayed on the tab.
+     * @param icon The active icon displayed on the tab.
+     * @param component The component associated with the tab.
+     * @param tip The tooltip associated with the tab.
+     */
+    protected Page(String title, Icon icon, Component component, String tip)
+    {
+      this.title = title;
+      this.icon = icon;
+      this.component = component;
+      this.tip = tip;
+    }
+
+    /**
+     * This method returns the component associated with the tab.
+     *
+     * @return The component associated with the tab.
+     */
+    public Component getComponent()
+    {
+      return component;
+    }
+
+    /**
+     * This method sets the component associated with the tab.
+     *
+     * @param c The component associated with the tab.
+     */
+    public void setComponent(Component c)
+    {
+      this.component = c;
+    }
+
+    /**
+     * This method returns the tooltip string.
+     *
+     * @return The tooltip string.
+     */
+    public String getTip()
+    {
+      return tip;
+    }
+
+    /**
+     * This method sets the tooltip string.
+     *
+     * @param tip The tooltip string.
+     */
+    public void setTip(String tip)
+    {
+      this.tip = tip;
+    }
+
+    /**
+     * This method returns the background color.
+     *
+     * @return The background color.
+     */
+    public Color getBackground()
+    {
+      return bg;
+    }
+
+    /**
+     * This method sets the background color.
+     *
+     * @param background The background color.
+     */
+    public void setBackground(Color background)
+    {
+      bg = background;
+    }
+
+    /**
+     * This method returns the foreground color.
+     *
+     * @return The foreground color.
+     */
+    public Color getForeground()
+    {
+      return fg;
+    }
+
+    /**
+     * This method sets the foreground color.
+     *
+     * @param foreground The foreground color.
+     */
+    public void setForeground(Color foreground)
+    {
+      fg = foreground;
+    }
+
+    /**
+     * This method returns the title associated with the tab.
+     *
+     * @return The title of the tab.
+     */
+    public String getTitle()
+    {
+      return title;
+    }
+
+    /**
+     * This method sets the title of the tab.
+     *
+     * @param text The title of the tab.
+     */
+    public void setTitle(String text)
+    {
+      title = text;
+      if (title != null && title.length() <= underlinedChar)
+        setDisplayedMnemonicIndex(title.length() - 1);      
+    }
+
+    /**
+     * This method returns the active icon.
+     *
+     * @return The active icon.
+     */
+    public Icon getIcon()
+    {
+      return icon;
+    }
+
+    /**
+     * This method sets the active icon.
+     *
+     * @param icon The active icon.
+     */
+    public void setIcon(Icon icon)
+    {
+      this.icon = icon;
+    }
+
+    /**
+     * This method returns the disabled icon.
+     *
+     * @return The disabled icon.
+     */
+    public Icon getDisabledIcon()
+    {
+      if (disabledIcon == null && icon instanceof ImageIcon)
+	setDisabledIcon(icon);
+      return disabledIcon;
+    }
+
+    /**
+     * This method sets the disabled icon.
+     *
+     * @param disabledIcon The disabled icon.
+     */
+    public void setDisabledIcon(Icon disabledIcon)
+    {
+      this.disabledIcon = disabledIcon;
+    }
+
+    /**
+     * This method returns whether the tab is enabled.
+     *
+     * @return Whether the tab is enabled.
+     */
+    public boolean isEnabled()
+    {
+      return enabled;
+    }
+
+    /**
+     * This method sets whether the tab is enabled.
+     *
+     * @param enabled Whether this tab is enabled.
+     */
+    public void setEnabled(boolean enabled)
+    {
+      this.enabled = enabled;
+    }
+
+    /**
+     * This method returns the mnemonic.
+     *
+     * @return The mnemonic.
+     */
+    public int getMnemonic()
+    {
+      return (int) mnemonicKey;
     }
-    
-    public TabbedPaneUI getUI() {
-        return (TabbedPaneUI)ui;
+
+    /**
+     * This method sets the mnemonic. If the title is set, it will update the
+     * mnemonicIndex.
+     *
+     * @param key The mnemonic.
+     */
+    public void setMnemonic(int key)
+    {
+      setMnemonic((char) key);
     }
-    
-    public void updateUI()
+
+    /**
+     * This method sets the mnemonic. If the title is set, it will update the
+     * mnemonicIndex.
+     *
+     * @param aChar The mnemonic.
+     */
+    public void setMnemonic(char aChar)
     {
-        setUI((TabbedPaneUI)UIManager.getUI(this));
+      mnemonicKey = aChar;
+      if (title != null)
+	setDisplayedMnemonicIndex(title.indexOf(mnemonicKey));
     }
-    
-    public AccessibleContext getAccessibleContext()
+
+    /**
+     * This method returns the mnemonicIndex.
+     *
+     * @return The mnemonicIndex.
+     */
+    public int getDisplayedMnemonicIndex()
     {
-	return null;
+      return underlinedChar;
     }
-    
-   protected  String paramString()
+
+    /**
+     * This method sets the mnemonicIndex.
+     *
+     * @param index The mnemonicIndex.
+     *
+     * @throws IllegalArgumentException If index less than -1 || index greater
+     *         or equal to title.length.
+     */
+    public void setDisplayedMnemonicIndex(int index)
+                                   throws IllegalArgumentException
     {
-	return "JTabbedPane";
+      if (index < -1 || title != null && index >= title.length())
+	throw new IllegalArgumentException();
+
+      if (title == null || title.charAt(index) != mnemonicKey)
+	index = -1;
+
+      underlinedChar = index;
     }
+  }
+
+  /** Fired in a PropertyChangeEvent when the "model" property changes. */
+  public static final String MODEL_CHANGED_PROPERTY = "model";
+
+  /**
+   * Fired in a PropertyChangeEvent when the "tabPlacement" property changes.
+   */
+  public static final String TAB_PLACEMENT_CHANGED_PROPERTY = "tabPlacement";
+
+  /**
+   * Fired in a PropertyChangeEvent when the "tabLayoutPolicy" property
+   * changes.
+   */
+  public static final String TAB_LAYOUT_POLICY_CHANGED_PROPERTY = "tabLayoutPolicy";
+
+  /** The changeEvent used to fire changes to listeners. */
+  protected ChangeEvent changeEvent;
+
+  /** The listener that listens to the model. */
+  protected ChangeListener changeListener;
+
+  /** The model that describes this JTabbedPane. */
+  protected SingleSelectionModel model;
+
+  /** Indicates that the TabbedPane is in scrolling mode. */
+  static int SCROLL_TAB_LAYOUT = 0;
+
+  /** Indicates that the TabbedPane is in wrap mode. */
+  static int WRAP_TAB_LAYOUT = 1;
+
+  /** The current tabPlacement of the TabbedPane. */
+  protected int tabPlacement = SwingConstants.TOP;
+
+  /** The current tabLayoutPolicy of the TabbedPane. */
+  private transient int layoutPolicy;
+
+  /** The list of tabs associated with the TabbedPane. */
+  transient Vector tabs = new Vector();
+
+  /**
+   * Creates a new JTabbedPane object with tabs on top and using wrap tab
+   * layout.
+   */
+  public JTabbedPane()
+  {
+    this(SwingConstants.TOP, WRAP_TAB_LAYOUT);
+  }
+
+  /**
+   * Creates a new JTabbedPane object using wrap tab layout  and the given
+   * tabPlacement.
+   *
+   * @param tabPlacement Where the tabs will be placed.
+   */
+  public JTabbedPane(int tabPlacement)
+  {
+    this(tabPlacement, WRAP_TAB_LAYOUT);
+  }
+
+  /**
+   * Creates a new JTabbedPane object with the given tabPlacement and
+   * tabLayoutPolicy.
+   *
+   * @param tabPlacement Where the tabs will be placed.
+   * @param tabLayoutPolicy The way tabs will be placed.
+   *
+   * @throws IllegalArgumentException If tabLayoutPolicy or tabPlacement are
+   *         not valid.
+   */
+  public JTabbedPane(int tabPlacement, int tabLayoutPolicy)
+  {
+    if (tabPlacement != TOP && tabPlacement != BOTTOM && tabPlacement != RIGHT
+        && tabPlacement != LEFT)
+      throw new IllegalArgumentException("tabPlacement is not valid.");
+    if (tabLayoutPolicy != SCROLL_TAB_LAYOUT
+        && tabLayoutPolicy != WRAP_TAB_LAYOUT)
+      throw new IllegalArgumentException("tabLayoutPolicy is not valid.");
+    this.tabPlacement = tabPlacement;
+    layoutPolicy = tabLayoutPolicy;
+
+    changeEvent = new ChangeEvent(this);
+    changeListener = createChangeListener();
+
+    model = new DefaultSingleSelectionModel();
+    model.addChangeListener(changeListener);
+
+    updateUI();
+  }
+
+  /**
+   * This method returns the UI used to display the JTabbedPane.
+   *
+   * @return The UI used to display the JTabbedPane.
+   */
+  public TabbedPaneUI getUI()
+  {
+    return (TabbedPaneUI) ui;
+  }
+
+  /**
+   * This method sets the UI used to display the JTabbedPane.
+   *
+   * @param ui The UI used to display the JTabbedPane.
+   */
+  public void setUI(TabbedPaneUI ui)
+  {
+    super.setUI(ui);
+  }
+
+  /**
+   * This method restores the UI to the defaults given by the UIManager.
+   */
+  public void updateUI()
+  {
+    setUI((TabbedPaneUI) UIManager.getUI(this));
+    invalidate();
+  }
+
+  /**
+   * This method returns a string identifier that  is used to determine which
+   * UI will be used with  the JTabbedPane.
+   *
+   * @return A string identifier for the UI.
+   */
+  public String getUIClassID()
+  {
+    return "TabbedPaneUI";
+  }
+
+  /**
+   * This method creates a ChangeListener that is used to  listen to the model
+   * for events.
+   *
+   * @return A ChangeListener to listen to the model.
+   */
+  protected ChangeListener createChangeListener()
+  {
+    return new ModelListener();
+  }
+
+  /**
+   * This method adds a ChangeListener to the JTabbedPane.
+   *
+   * @param l The ChangeListener to add.
+   */
+  public void addChangeListener(ChangeListener l)
+  {
+    listenerList.add(ChangeListener.class, l);
+  }
+
+  /**
+   * This method removes a ChangeListener to the JTabbedPane.
+   *
+   * @param l The ChangeListener to remove.
+   */
+  public void removeChangeListener(ChangeListener l)
+  {
+    listenerList.remove(ChangeListener.class, l);
+  }
+
+  /**
+   * This method fires a ChangeEvent to all the JTabbedPane's ChangeListeners.
+   */
+  protected void fireStateChanged()
+  {
+    Object[] changeListeners = listenerList.getListenerList();
+    if (changeEvent == null)
+      changeEvent = new ChangeEvent(this);
+    for (int i = changeListeners.length - 2; i >= 0; i -= 2)
+      {
+	if (changeListeners[i] == ChangeListener.class)
+	  ((ChangeListener) changeListeners[i + 1]).stateChanged(changeEvent);
+      }
+  }
+
+  /**
+   * This method returns all ChangeListeners registered with the JTabbedPane.
+   *
+   * @return The ChangeListeners registered with the JTabbedPane.
+   */
+  public ChangeListener[] getChangeListeners()
+  {
+    return (ChangeListener[]) super.getListeners(ChangeListener.class);
+  }
+
+  /**
+   * This method returns the model used with the JTabbedPane.
+   *
+   * @return The JTabbedPane's model.
+   */
+  public SingleSelectionModel getModel()
+  {
+    return model;
+  }
+
+  /**
+   * This method changes the model property of the JTabbedPane.
+   *
+   * @param model The new model to use with the JTabbedPane.
+   */
+  public void setModel(SingleSelectionModel model)
+  {
+    if (model != this.model)
+      {
+	SingleSelectionModel oldModel = this.model;
+	this.model.removeChangeListener(changeListener);
+	this.model = model;
+	this.model.addChangeListener(changeListener);
+	firePropertyChange(MODEL_CHANGED_PROPERTY, oldModel, this.model);
+      }
+  }
+
+  /**
+   * This method returns the tabPlacement.
+   *
+   * @return The tabPlacement used with the JTabbedPane.
+   */
+  public int getTabPlacement()
+  {
+    return tabPlacement;
+  }
+
+  /**
+   * This method changes the tabPlacement property of the JTabbedPane.
+   *
+   * @param tabPlacement The tabPlacement to use.
+   *
+   * @throws IllegalArgumentException If tabPlacement is not one of TOP,
+   *         BOTTOM, LEFT, or RIGHT.
+   */
+  public void setTabPlacement(int tabPlacement)
+  {
+    if (tabPlacement != TOP && tabPlacement != BOTTOM && tabPlacement != RIGHT
+        && tabPlacement != LEFT)
+      throw new IllegalArgumentException("tabPlacement is not valid.");
+    if (tabPlacement != this.tabPlacement)
+      {
+	int oldPlacement = this.tabPlacement;
+	this.tabPlacement = tabPlacement;
+	firePropertyChange(TAB_PLACEMENT_CHANGED_PROPERTY, oldPlacement,
+	                   this.tabPlacement);
+      }
+  }
+
+  /**
+   * This method returns the tabLayoutPolicy.
+   *
+   * @return The tabLayoutPolicy.
+   */
+  public int getTabLayoutPolicy()
+  {
+    return layoutPolicy;
+  }
+
+  /**
+   * This method changes the tabLayoutPolicy property of the JTabbedPane.
+   *
+   * @param tabLayoutPolicy The tabLayoutPolicy to use.
+   *
+   * @throws IllegalArgumentException If tabLayoutPolicy is not one of
+   *         SCROLL_TAB_LAYOUT or WRAP_TAB_LAYOUT.
+   */
+  public void setTabLayoutPolicy(int tabLayoutPolicy)
+  {
+    if (tabLayoutPolicy != SCROLL_TAB_LAYOUT
+        && tabLayoutPolicy != WRAP_TAB_LAYOUT)
+      throw new IllegalArgumentException("tabLayoutPolicy is not valid.");
+    if (tabLayoutPolicy != layoutPolicy)
+      {
+	int oldPolicy = layoutPolicy;
+	layoutPolicy = tabLayoutPolicy;
+	firePropertyChange(TAB_LAYOUT_POLICY_CHANGED_PROPERTY, oldPolicy,
+	                   layoutPolicy);
+      }
+  }
+
+  /**
+   * This method returns the index of the tab that is currently selected.
+   *
+   * @return The index of the selected tab.
+   */
+  public int getSelectedIndex()
+  {
+    return model.getSelectedIndex();
+  }
+
+  /**
+   * This method checks the index.
+   *
+   * @param index The index to check.
+   */
+  private void checkIndex(int index, int start, int end)
+  {
+    if (index < start || index >= end)
+      throw new IndexOutOfBoundsException("Index < " + start + " || Index >= " + end);
+  }
+
+  /**
+   * This method sets the selected index. This method
+   * will hide the old component and show the new component.
+   *
+   * @param index The index to set it at.
+   */
+  public void setSelectedIndex(int index)
+  {
+    checkIndex(index, -1, tabs.size());
+    if (index != getSelectedIndex())
+      {
+	if (getSelectedIndex() != -1)
+	  getSelectedComponent().hide();
+	if (index != -1)
+	  getComponentAt(index).show();
+      }
+    model.setSelectedIndex(index);
+  }
+
+  /**
+   * This method returns the component at the selected index.
+   *
+   * @return The component at the selected index.
+   */
+  public Component getSelectedComponent()
+  {
+    return getComponentAt(getSelectedIndex());
+  }
+
+  /**
+   * This method sets the component at the selected index.
+   *
+   * @param c The component associated with the selected index.
+   */
+  public void setSelectedComponent(Component c)
+  {
+    if (c.getParent() == this)
+      setSelectedIndex(indexOfComponent(c));
+    else
+      setComponentAt(getSelectedIndex(), c);
+  }
+
+  /**
+   * This method inserts tabs into JTabbedPane. This includes
+   * adding the component to the JTabbedPane and hiding it.
+   *
+   * @param title The title of the tab.
+   * @param icon The tab's icon.
+   * @param component The component associated with the tab.
+   * @param tip The tooltip for the tab.
+   * @param index The index to insert the tab at.
+   */
+  public void insertTab(String title, Icon icon, Component component,
+                        String tip, int index)
+  {
+    Page p = new Page(title, icon, component, tip);
+    tabs.insertElementAt(p, index);
+
+    // Hide the component so we don't see it. Do it before we parent it
+    // so we don't trigger a repaint.
+    component.hide();
+    super.add(component);
+  
+    if (getSelectedIndex() == -1)
+      setSelectedIndex(0);
+
+    layout();
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   *
+   * @param title The title of the tab.
+   * @param icon The icon for the tab.
+   * @param component The associated component.
+   * @param tip The associated tooltip.
+   */
+  public void addTab(String title, Icon icon, Component component, String tip)
+  {
+    insertTab(title, icon, component, tip, tabs.size());
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   *
+   * @param title The title of the tab.
+   * @param icon The icon for the tab.
+   * @param component The associated component.
+   */
+  public void addTab(String title, Icon icon, Component component)
+  {
+    insertTab(title, icon, component, null, tabs.size());
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   *
+   * @param title The title of the tab.
+   * @param component The associated component.
+   */
+  public void addTab(String title, Component component)
+  {
+    insertTab(title, null, component, null, tabs.size());
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   * The title of the tab is the Component's name.
+   * If the Component is an instance of UIResource, it doesn't
+   * add the tab and instead add the component directly to the
+   * JTabbedPane.
+   *
+   * @param component The associated component.
+   *
+   * @return The Component that was added.  
+   */
+  public Component add(Component component)
+  {
+    if (component instanceof UIResource)
+      super.add(component);
+    else
+      insertTab(component.getName(), null, component, null, tabs.size());
+    return component;
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   * If the Component is an instance of UIResource, it doesn't
+   * add the tab and instead add the component directly to the
+   * JTabbedPane.
+   *
+   * @param title The title of the tab.
+   * @param component The associated component.
+   *
+   * @return The Component that was added.
+   */
+   public Component add(String title, Component component)
+  {
+    if (component instanceof UIResource)
+      super.add(component);
+    else
+      insertTab(title, null, component, null, tabs.size());
+    return component;
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   * If the Component is an instance of UIResource, it doesn't
+   * add the tab and instead add the component directly to the
+   * JTabbedPane.
+   *
+   * @param component The associated component.
+   * @param index The index to insert the tab at.
+   *
+   * @return The Component that was added.
+   */
+  public Component add(Component component, int index)
+  {
+    if (component instanceof UIResource)
+      super.add(component);
+    else
+      insertTab(component.getName(), null, component, null, index);
+    return component;
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   * If the Component is an instance of UIResource, it doesn't
+   * add the tab and instead add the component directly to the
+   * JTabbedPane. If the constraints object is an icon, it
+   * will be used as the tab's icon. If the constraints object
+   * is a string, we will use it as the title.
+   *
+   * @param component The associated component.
+   * @param constraints The constraints object.
+   */
+  public void add(Component component, Object constraints)
+  {
+    add(component, constraints, tabs.size());
+  }
+
+  /**
+   * This method adds a tab to the JTabbedPane.
+   * If the Component is an instance of UIResource, it doesn't
+   * add the tab and instead add the component directly to the
+   * JTabbedPane. If the constraints object is an icon, it
+   * will be used as the tab's icon. If the constraints object
+   * is a string, we will use it as the title.
+   *
+   * @param component The associated component.
+   * @param constraints The constraints object.
+   * @param index The index to insert the tab at.
+   */
+  public void add(Component component, Object constraints, int index)
+  {
+    if (component instanceof UIResource)
+      super.add(component);
+    else
+      {
+	if (constraints instanceof String)
+	  insertTab((String) constraints, null, component, null, index);
+	else
+	  insertTab(component.getName(),
+	            (constraints instanceof Icon) ? (Icon) constraints : null,
+	            component, null, index);
+      }
+  }
+
+  /**
+   * The tab and it's associated component are removed. After
+   * the component has been removed from the JTabbedPane, it's
+   * set visible to ensure that it can be seen.
+   *
+   * @param index The index of the tab to remove.
+   *
+   * @throws IndexOutOfBoundsException If the index is not in range.
+   */
+  public void removeTabAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    Component c = getComponentAt(index);
+    super.remove(c);
+    c.show();
+    tabs.remove(index);
+  }
+
+  /**
+   * This method removes the component from the JTabbedPane. After
+   * the component has been removed from the JTabbedPane, it's 
+   * set visible to ensure that it can be seen.
+   *
+   * @param component The Component to remove.
+   */
+  public void remove(Component component)
+  {
+    // This simply removes the component.
+    int index = indexOfComponent(component);
+    super.remove(component);
+    component.show();
+    setComponentAt(index, null);
+  }
+
+  /**
+   * This method removes the tab and component from the JTabbedPane.
+   * It simply calls removeTabAt(int index).
+   *
+   * @param index The index of the tab to remove.
+   */
+  public void remove(int index)
+  {
+    removeTabAt(index);
+  }
+
+  /**
+   * This method removes all tabs and associated components
+   * from the JTabbedPane.
+   */
+  public void removeAll()
+  {
+    for (int i = tabs.size() - 1; i >= 0; i--)
+      removeTabAt(i);
+  }
+
+  /**
+   * This method returns how many tabs are in the JTabbedPane.
+   *
+   * @return The number of tabs in the JTabbedPane.
+   */
+  public int getTabCount()
+  {
+    return tabs.size();
+  }
+
+  /**
+   * This method returns the number of runs used 
+   * to paint the JTabbedPane.
+   *
+   * @return The number of runs.
+   */
+  public int getTabRunCount()
+  {
+    return ((TabbedPaneUI) ui).getTabRunCount(this);
+  }
+
+  /**
+   * This method returns the tab title given the index.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The title for the tab.
+   */
+  public String getTitleAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getTitle();
+  }
+
+  /**
+   * This method returns the active icon given the index.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The active icon for the tab.
+   */
+  public Icon getIconAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getIcon();
+  }
+
+  /**
+   * This method returns the disabled icon given the index.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The disabled icon for the tab.
+   */
+  public Icon getDisabledIconAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getDisabledIcon();
+  }
+
+  /**
+   * This method returns the tooltip string for the tab.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The tooltip string for the tab.
+   */
+  public String getToolTipTextAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getTip();
+  }
+
+  /**
+   * This method returns the foreground color for the tab.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The foreground color for the tab.
+   */
+  public Color getForegroundAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getForeground();
+  }
+
+  /**
+   * This method returns the background color for the tab.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The background color for the tab.
+   */
+  public Color getBackgroundAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getBackground();
+  }
+
+  /**
+   * This method returns the component associated with the tab.
+   *
+   * @param index The index of the tab.
+   *
+   * @return The component associated with the tab.
+   */
+  public Component getComponentAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).getComponent();
+  }
+
+  /**
+   * This method returns whether this tab is enabled.
+   * Disabled tabs cannot be selected.
+   *
+   * @param index The index of the tab.
+   *
+   * @return Whether the tab is enabled.
+   */
+  public boolean isEnabledAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((Page) tabs.elementAt(index)).isEnabled();
+  }
+
+  /**
+   * This method returns the mnemonic for the tab.
+   *
+   * @param tabIndex The index of the tab.
+   *
+   * @return The mnemonic for the tab.
+   */
+  public int getMnemonicAt(int tabIndex)
+  {
+    checkIndex(tabIndex, 0, tabs.size());
+    return ((Page) tabs.elementAt(tabIndex)).getMnemonic();
+  }
+
+  /**
+   * This method returns the mnemonic index for the tab.
+   *
+   * @param tabIndex The index of the tab.
+   *
+   * @return The mnemonic index for the tab.
+   */
+  public int getDisplayedMnemonicIndexAt(int tabIndex)
+  {
+    checkIndex(tabIndex, 0, tabs.size());
+    return ((Page) tabs.elementAt(tabIndex)).getDisplayedMnemonicIndex();
+  }
+
+  /**
+   * This method returns the bounds of the tab given
+   * the index.
+   *
+   * @param index The index of the tab.
+   *
+   * @return A rectangle describing the bounds of the tab.
+   */
+  public Rectangle getBoundsAt(int index)
+  {
+    checkIndex(index, 0, tabs.size());
+    return ((TabbedPaneUI) ui).getTabBounds(this, index);
+  }
+
+  /**
+   * This method sets the title of the tab.
+   *
+   * @param index The index of the tab.
+   * @param title The new title.
+   */
+  public void setTitleAt(int index, String title)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setTitle(title);
+  }
+
+  /**
+   * This method sets the icon of the tab.
+   *
+   * @param index The index of the tab.
+   * @param icon The new icon.
+   */
+  public void setIconAt(int index, Icon icon)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setIcon(icon);
+  }
+
+  /**
+   * This method sets the disabled icon of the tab.
+   *
+   * @param index The index of the tab.
+   * @param disabledIcon The new disabled icon.
+   */
+  public void setDisabledIconAt(int index, Icon disabledIcon)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setDisabledIcon(disabledIcon);
+  }
+
+  /**
+   * This method sets the tooltip text of the tab.
+   *
+   * @param index The index of the tab.
+   * @param toolTipText The tooltip text.
+   */
+  public void setToolTipTextAt(int index, String toolTipText)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setTip(toolTipText);
+  }
+
+  /**
+   * This method sets the background color of the tab.
+   *
+   * @param index The index of the tab.
+   * @param background The background color of the tab.
+   */
+  public void setBackgroundAt(int index, Color background)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setBackground(background);
+  }
+
+  /**
+   * This method sets the foreground color of the tab.
+   *
+   * @param index The index of the tab.
+   * @param foreground The foreground color of the tab.
+   */
+  public void setForegroundAt(int index, Color foreground)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setForeground(foreground);
+  }
+
+  /**
+   * This method sets whether the tab is enabled.
+   *
+   * @param index The index of the tab.
+   * @param enabled Whether the tab is enabled.
+   */
+  public void setEnabledAt(int index, boolean enabled)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setEnabled(enabled);
+  }
+
+  /**
+   * This method sets the component associated with the tab.
+   *
+   * @param index The index of the tab.
+   * @param component The component associated with the tab.
+   */
+  public void setComponentAt(int index, Component component)
+  {
+    checkIndex(index, 0, tabs.size());
+    ((Page) tabs.elementAt(index)).setEnabled(enabled);
+  }
+
+  /**
+   * This method sets the displayed mnemonic index of the tab.
+   *
+   * @param tabIndex The index of the tab.
+   * @param mnemonicIndex The mnemonic index.
+   */
+  public void setDisplayedMnemonicIndexAt(int tabIndex, int mnemonicIndex)
+  {
+    checkIndex(tabIndex, 0, tabs.size());
+    ((Page) tabs.elementAt(tabIndex)).setDisplayedMnemonicIndex(mnemonicIndex);
+  }
+
+  /**
+   * This method sets the mnemonic for the tab.
+   *
+   * @param tabIndex The index of the tab.
+   * @param mnemonic The mnemonic.
+   */
+  public void setMnemonicAt(int tabIndex, int mnemonic)
+  {
+    checkIndex(tabIndex, 0, tabs.size());
+    ((Page) tabs.elementAt(tabIndex)).setMnemonic(mnemonic);
+  }
+
+  /**
+   * This method finds the index of a tab given the title.
+   *
+   * @param title The title that belongs to a tab.
+   *
+   * @return The index of the tab that has the title or -1 if not found.
+   */
+  public int indexOfTab(String title)
+  {
+    int index = -1;
+    for (int i = 0; i < tabs.size(); i++)
+      {
+	if (((Page) tabs.elementAt(i)).getTitle().equals(title))
+	  {
+	    index = i;
+	    break;
+	  }
+      }
+    return index;
+  }
+
+  /**
+   * This method finds the index of a tab given the icon.
+   *
+   * @param icon The icon that belongs to a tab.
+   *
+   * @return The index of the tab that has the icon or -1 if not found.
+   */
+  public int indexOfTab(Icon icon)
+  {
+    int index = -1;
+    for (int i = 0; i < tabs.size(); i++)
+      {
+	if (((Page) tabs.elementAt(i)).getIcon() == icon)
+	  {
+	    index = i;
+	    break;
+	  }
+      }
+    return index;
+  }
+
+  /**
+   * This method finds the index of a tab given the component.
+   *
+   * @param component A component associated with a tab.
+   *
+   * @return The index of the tab that has this component or -1 if not found.
+   */
+  public int indexOfComponent(Component component)
+  {
+    int index = -1;
+    for (int i = 0; i < tabs.size(); i++)
+      {
+	if (((Page) tabs.elementAt(i)).getComponent() == component)
+	  {
+	    index = i;
+	    break;
+	  }
+      }
+    return index;
+  }
+
+  /**
+   * This method returns a tab index given an (x,y) location. The origin
+   * of the (x,y) pair will be the JTabbedPane's top left position. The 
+   * tab returned will be the one that contains the point. This method is 
+   * delegated to the UI.
+   *
+   * @param x The x coordinate of the point.
+   * @param y The y coordinate of the point.
+   *
+   * @return The index of the tab that contains the point.
+   */
+  public int indexAtLocation(int x, int y)
+  {
+    return ((TabbedPaneUI) ui).tabForCoordinate(this, x, y);
+  }
+
+  /**
+   * This method returns the tooltip text given a mouse event.
+   *
+   * @param event The mouse event.
+   *
+   * @return The tool tip text that is associated with this mouse event.
+   */
+  public String getToolTipText(MouseEvent event)
+  {
+    int index = indexAtLocation(event.getX(), event.getY());
+    return ((Page) tabs.elementAt(index)).getTip();
+  }
+
+  /**
+   * This method returns a string representation of this JTabbedPane. It
+   * is mainly used for debugging purposes.
+   *
+   * @return A string representation of this JTabbedPane.
+   */
+  protected String paramString()
+  {
+    return "JTabbedPane";
+  }
+
+  /**
+   * DOCUMENT ME!
+   *
+   * @return DOCUMENT ME!
+   */
+  public AccessibleContext getAccessibleContext()
+  {
+    if (accessibleContext == null)
+      accessibleContext = new AccessibleJTabbedPane(this);
+    return accessibleContext;
+  }
 }
Index: javax/swing/plaf/basic/BasicLookAndFeel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java,v
retrieving revision 1.4.2.5
diff -u -r1.4.2.5 BasicLookAndFeel.java
--- javax/swing/plaf/basic/BasicLookAndFeel.java	26 Feb 2004 00:34:02 -0000	1.4.2.5
+++ javax/swing/plaf/basic/BasicLookAndFeel.java	23 Mar 2004 14:27:48 -0000
@@ -703,9 +703,9 @@
         "ctrl UP", "requestFocus",
         "ctrl KP_UP", "requestFocus"
       }),
-      "TabbedPane.background", new ColorUIResource(Color.lightGray),
+      "TabbedPane.background", new ColorUIResource(Color.GRAY),
       "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
-      "TabbedPane.darkShadow", new ColorUIResource(Color.black),
+      "TabbedPane.darkShadow", new ColorUIResource(Color.darkGray),
       "TabbedPane.focus", new ColorUIResource(Color.black),
       "TabbedPane.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
         "LEFT",  "navigateLeft",
@@ -725,8 +725,10 @@
       "TabbedPane.lightHighlight", new ColorUIResource(Color.white),
       "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
       "TabbedPane.shadow", new ColorUIResource(Color.gray),
-      "TabbedPane.tabAreaInsets", new InsetsUIResource(3, 2, 0, 2),
-      "TabbedPane.tabInsets", new InsetsUIResource(0, 4, 1, 4),
+      "TabbedPane.tabbedPaneTabAreaInsets", new InsetsUIResource(3, 2, 1, 2),
+      "TabbedPane.tabbedPaneTabInsets", new InsetsUIResource(1, 4, 1, 4),
+      "TabbedPane.tabbedPaneContentBorderInsets", new InsetsUIResource(3, 2, 1, 2),
+      "TabbedPane.tabbedPaneTabPadInsets", new InsetsUIResource(1, 1, 1, 1),
       "TabbedPane.tabRunOverlay", new Integer(2),
       "TabbedPane.textIconGap", new Integer(4),
       "Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
Index: javax/swing/plaf/basic/BasicArrowButton.java
===================================================================
RCS file: javax/swing/plaf/basic/BasicArrowButton.java
diff -N javax/swing/plaf/basic/BasicArrowButton.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ javax/swing/plaf/basic/BasicArrowButton.java	23 Mar 2004 14:27:49 -0000
@@ -0,0 +1,363 @@
+/* BasicArrowButton.java
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.SwingConstants;
+
+
+/**
+ * This class draws simple arrow buttons for the Basic Look and Feel.
+ */
+public class BasicArrowButton extends JButton implements SwingConstants
+{
+  /**
+   * A private helper class that draws icons.
+   */
+  private class arrowIcon implements Icon
+  {
+    /** The polygon that describes the icon. */
+    private Polygon arrow;
+
+    /** The size of the icon. */
+    private int size = 10;
+
+    /**
+     * Creates a new arrowIcon object using the given arrow polygon.
+     *
+     * @param arrow The polygon that describes the arrow.
+     */
+    public arrowIcon(Polygon arrow)
+    {
+      this.arrow = arrow;
+    }
+
+    /**
+     * Returns the height of the icon.
+     *
+     * @return The height of the icon.
+     */
+    public int getIconHeight()
+    {
+      return size;
+    }
+
+    /**
+     * Returns the width of the icon.
+     *
+     * @return The width of the icon.
+     */
+    public int getIconWidth()
+    {
+      return size;
+    }
+
+    /**
+     * Sets the size of the icon.
+     *
+     * @param size The size of the icon.
+     */
+    public void setSize(int size)
+    {
+      this.size = size;
+    }
+
+    /**
+     * Sets the arrow polygon.
+     *
+     * @param arrow The arrow polygon.
+     */
+    public void setArrow(Polygon arrow)
+    {
+      this.arrow = arrow;
+    }
+
+    /**
+     * Paints the icon.
+     *
+     * @param c The Component to paint for.
+     * @param g The Graphics object to draw with.
+     * @param x The X coordinate to draw at.
+     * @param y The Y coordinate to draw at.
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      Color arrowColor;
+      if (c.isEnabled())
+	arrowColor = darkShadow;
+      else
+	arrowColor = shadow;
+
+      paintIconImpl(g, x, y, arrowColor);
+    }
+
+    /**
+     * This method does the actual painting work.
+     *
+     * @param g The Graphics object to paint with.
+     * @param x The x coordinate to paint at.
+     * @param y The y coordinate to paint at.
+     * @param arrowColor The color to paint the arrow with.
+     */
+    public void paintIconImpl(Graphics g, int x, int y, Color arrowColor)
+    {
+      g.translate(x, y);
+
+      Color saved = g.getColor();
+
+      g.setColor(arrowColor);
+
+      g.fillPolygon(arrow);
+
+      g.setColor(saved);
+      g.translate(-x, -y);
+    }
+  }
+
+  /** The direction to point in. */
+  protected int direction;
+
+  /** The color the arrow is painted in if disabled and the bottom and
+   * right edges of the button. */
+  private transient Color shadow = Color.BLACK;
+
+  /** The color the arrow is painted in if enabled and the bottom and
+   * right edges of the button. */
+  private transient Color darkShadow = Color.BLACK;
+
+  /** The top and left edges of the button. */
+  private transient Color highlight = Color.BLACK;
+
+  /**
+   * Creates a new BasicArrowButton object.
+   *
+   * @param direction The direction the arrow points in.
+   */
+  public BasicArrowButton(int direction)
+  {
+    super();
+    setDirection(direction);
+  }
+
+  /**
+   * Creates a new BasicArrowButton object with the given colors and 
+   * direction.
+   *
+   * @param direction The direction to point in.
+   * @param background The background color.
+   * @param shadow The shadow color.
+   * @param darkShadow The dark shadow color.
+   * @param highlight The highlight color.
+   */
+  public BasicArrowButton(int direction, Color background, Color shadow,
+                          Color darkShadow, Color highlight)
+  {
+    this(direction);
+    setBackground(background);
+    this.shadow = shadow;
+    this.darkShadow = darkShadow;
+    this.highlight = highlight;
+  }
+
+  /**
+   * This method returns the direction of the arrow.
+   *
+   * @return The direction of the arrow.
+   */
+  public int getDirection()
+  {
+    return direction;
+  }
+
+  /**
+   * This method changes the direction of the arrow.
+   *
+   * @param dir The new direction of the arrow.
+   */
+  public void setDirection(int dir)
+  {
+    Polygon arrow = getArrow(dir, 10);
+    if (getIcon() == null)
+      setIcon(new arrowIcon(arrow));
+    else
+      ((arrowIcon) getIcon()).setArrow(arrow);
+    this.direction = direction;
+  }
+
+  /**
+   * This method paints the arrow button.
+   *
+   * @param g The Graphics object to paint with.
+   */
+  public void paint(Graphics g)
+  {
+    super.paint(g);
+    Rectangle bounds = getBounds();
+
+    Color saved = g.getColor();
+    g.setColor(highlight);
+
+    g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height);
+    g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);
+
+    g.setColor(shadow);
+
+    g.drawLine(bounds.x + 1, bounds.y + bounds.height - 1,
+               bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
+    g.drawLine(bounds.x + bounds.width - 1, bounds.y + 1,
+               bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
+
+    g.setColor(darkShadow);
+
+    g.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width,
+               bounds.y + bounds.height);
+    g.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width,
+               bounds.y + bounds.height);
+
+    g.setColor(saved);
+  }
+
+  /**
+   * This method returns the preferred size of the arrow button.
+   *
+   * @return The preferred size.
+   */
+  public Dimension getPreferredSize()
+  {
+    return new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight());
+  }
+
+  /**
+   * This method returns the minimum size of the arrow button.
+   *
+   * @return The minimum size.
+   */
+  public Dimension getMinimumSize()
+  {
+    return getPreferredSize();
+  }
+
+  /**
+   * This method returns the maximum size of the arrow button.
+   *
+   * @return The maximum size.
+   */
+  public Dimension getMaximumSize()
+  {
+    return getPreferredSize();
+  }
+
+  /**
+   * The method paints a triangle with the given size and direction at
+   * the given x and y coordinates.
+   *
+   * @param g The Graphics object to paint with.
+   * @param x The x coordinate to paint at.
+   * @param y The y coordinate to paint at.
+   * @param size The size of the icon.
+   * @param direction The direction of the icon.
+   * @param isEnabled Whether it is enabled.
+   */
+  public void paintTriangle(Graphics g, int x, int y, int size, int direction,
+                            boolean isEnabled)
+  {
+    Polygon arrow = getArrow(direction, size);
+    arrowIcon arrowI = new arrowIcon(arrow);
+    arrowI.setSize(size);
+
+    Color arrowColor;
+    if (isEnabled())
+      arrowColor = darkShadow;
+    else
+      arrowColor = shadow;
+
+    arrowI.paintIconImpl(g, x, y, arrowColor);
+  }
+
+  /**
+   * This is a private helper that creates polygons for a given size 
+   * and direction.
+   *
+   * @param direction The direction of the arrow.
+   * @param size The size of the arrow.
+   *
+   * @return A new arrow polygon.
+   */
+  private Polygon getArrow(int direction, int size)
+  {
+    Polygon arrow;
+    double dsize = (double) size;
+
+    int two = (int) (dsize * 2 / 10);
+    int three = (int) (dsize * 3 / 10);
+    int five = (int) (dsize * 5 / 10);
+    int seven = (int) (dsize * 7 / 10);
+    int eight = (int) (dsize * 8 / 10);
+    switch (direction)
+      {
+      case NORTH:
+	arrow = new Polygon(new int[] { two, five, eight },
+	                    new int[] { seven, three, seven }, 3);
+	break;
+      case SOUTH:
+	arrow = new Polygon(new int[] { two, five, eight },
+	                    new int[] { three, seven, three }, 3);
+	break;
+      case EAST:
+      case RIGHT:
+	arrow = new Polygon(new int[] { three, seven, three },
+	                    new int[] { two, five, eight }, 3);
+	break;
+      case WEST:
+      case LEFT:
+	arrow = new Polygon(new int[] { seven, three, seven },
+	                    new int[] { two, five, eight }, 3);
+	break;
+      default:
+	throw new IllegalArgumentException("Invalid direction given.");
+      }
+    return arrow;
+  }
+}
Index: javax/swing/plaf/basic/BasicProgressBarUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicProgressBarUI.java,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 BasicProgressBarUI.java
--- javax/swing/plaf/basic/BasicProgressBarUI.java	19 Feb 2004 18:59:11 -0000	1.1.2.1
+++ javax/swing/plaf/basic/BasicProgressBarUI.java	23 Mar 2004 14:27:49 -0000
@@ -573,7 +573,7 @@
 	  }
       }
 
-    if (progressBar.isStringPainted())
+    if (progressBar.isStringPainted() && !progressBar.getString().equals(""))
       paintString(g, 0, 0, or.width, or.height, amountFull, insets);
     g.setColor(saved);
   }
@@ -605,7 +605,7 @@
     g.setColor(c.getForeground());
     g.fill3DRect(box.x, box.y, box.width, box.height, true);
 
-    if (progressBar.isStringPainted())
+    if (progressBar.isStringPainted() && !progressBar.getString().equals(""))
       paintString(g, 0, 0, or.width, or.height,
                   getAmountFull(insets, or.width, or.height), insets);
 
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.3
diff -u -r1.3 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	13 Jul 2003 15:29:11 -0000	1.3
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	23 Mar 2004 14:27:50 -0000
@@ -1,5 +1,5 @@
 /* BasicTabbedPaneUI.java
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -28,82 +28,3021 @@
 executable, regardless of the license terms of these independent
 modules, and to copy and distribute the resulting executable under
 terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
+independent module, the terms and conditions of7 the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
-
 package javax.swing.plaf.basic;
 
+import java.awt.Color;
 import java.awt.Component;
+import java.awt.Container;
 import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
 import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.Point;
+import java.awt.Polygon;
 import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.Exception;
+import javax.swing.Icon;
+import javax.swing.JButton;
 import javax.swing.JComponent;
+import javax.swing.JPanel;
 import javax.swing.JTabbedPane;
+import javax.swing.JViewport;
+import javax.swing.KeyStroke;
+import javax.swing.SingleSelectionModel;
 import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PanelUI;
 import javax.swing.plaf.TabbedPaneUI;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.ViewportUI;
+import javax.swing.plaf.basic.BasicGraphicsUtils;
+import javax.swing.text.View;
+
 
-public class BasicTabbedPaneUI extends TabbedPaneUI
-  implements SwingConstants
+/**
+ * This is the Basic Look and Feel's UI delegate for JTabbedPane.
+ */
+public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
 {
-    public static ComponentUI createUI(final JComponent c) 
+  /**
+   * A helper class that handles focus.
+   */
+  protected class FocusHandler extends FocusAdapter
+  {
+    /**
+     * This method is called when the component gains focus.
+     *
+     * @param e The FocusEvent.
+     */
+    public void focusGained(FocusEvent e)
     {
-	return new BasicTabbedPaneUI();
+      // FIXME: Implement.
     }
-    
-    public void installUI(final JComponent c) 
+
+    /**
+     * This method is called when the component loses focus.
+     *
+     * @param e The FocusEvent.
+     */
+    public void focusLost(FocusEvent e)
     {
-	super.installUI(c);
+      // FIXME: Implement.
+    }
+  }
+
+  /**
+   * A helper class for determining if mouse presses occur inside tabs and
+   * sets the index appropriately. In SCROLL_TAB_MODE, this class also
+   * handles the mouse clicks on the scrolling buttons.
+   */
+  protected class MouseHandler extends MouseAdapter
+  {
+    /**
+     * This method is called when the mouse is pressed. The index cannot
+     * change to a tab that is  not enabled.
+     *
+     * @param e The MouseEvent.
+     */
+    public void mousePressed(MouseEvent e)
+    {
+      int x = e.getX();
+      int y = e.getY();
+      int tabCount = tabPane.getTabCount();
+
+      if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+        {
+	  if (e.getSource() == incrButton)
+	    {
+	      System.out.println("SOURCE = INCREASE BUTTON");
+	      if (++currentScrollLocation >= tabCount)
+		currentScrollLocation = tabCount - 1;
+	      if (currentScrollLocation == tabCount - 1)
+		incrButton.setEnabled(false);
+	      else if (! decrButton.isEnabled())
+		decrButton.setEnabled(true);
+	      tabPane.layout();
+	      tabPane.repaint();
+	      System.out.println("FINISHED WITH MOUSE PRESS");
+	      return;
+	    }
+	  else if (e.getSource() == decrButton)
+	    {
+	      System.out.println("SOURCE = DECREASE BUTTON");
+	      if (--currentScrollLocation < 0)
+		currentScrollLocation = 0;
+	      if (currentScrollLocation == 0)
+		decrButton.setEnabled(false);
+	      else if (! incrButton.isEnabled())
+		incrButton.setEnabled(true);
+	      tabPane.layout();
+	      tabPane.repaint();
+	      System.out.println("FINISHED WITH MOUSE PRESS");
+	      return;
+	    }
+        }
+
+      int index = tabForCoordinate(tabPane, x, y);
+
+      // We need to check since there are areas where tabs cannot be
+      // e.g. in the inset area.
+      if (index != -1 && tabPane.isEnabledAt(index))
+	tabPane.setSelectedIndex(index);
     }
-    
-    public Dimension getPreferredSize(JComponent c) 
+  }
+
+  /**
+   * This class handles PropertyChangeEvents fired from the JTabbedPane.
+   */
+  protected class PropertyChangeHandler implements PropertyChangeListener
+  {
+    /**
+     * This method is called whenever one of the properties of the JTabbedPane
+     * changes.
+     *
+     * @param e The PropertyChangeEvent.
+     */
+    public void propertyChange(PropertyChangeEvent e)
+    {
+      if (e.getPropertyName().equals(JTabbedPane.TAB_LAYOUT_POLICY_CHANGED_PROPERTY))
+        {
+	  layoutManager = createLayoutManager();
+
+	  tabPane.setLayout(layoutManager);
+        }
+      else if (e.getPropertyName().equals(JTabbedPane.TAB_PLACEMENT_CHANGED_PROPERTY)
+               && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+        {
+	  incrButton = createIncreaseButton();
+	  decrButton = createDecreaseButton();
+        }
+      tabPane.layout();
+      tabPane.repaint();
+    }
+  }
+
+  /**
+   * A LayoutManager responsible for placing all the tabs and the visible
+   * component inside the JTabbedPane. This class is only used for
+   * WRAP_TAB_LAYOUT.
+   */
+  protected class TabbedPaneLayout implements LayoutManager
+  {
+    /**
+     * This method is called when a component is added to the JTabbedPane.
+     *
+     * @param name The name of the component.
+     * @param comp The component being added.
+     */
+    public void addLayoutComponent(String name, Component comp)
+    {
+      // Do nothing.
+    }
+
+    /**
+     * This method is called when the rectangles need to be calculated. It
+     * also fixes the size of the visible component.
+     */
+    public void calculateLayoutInfo()
+    {
+      calculateTabRects(tabPane.getTabPlacement(), tabPane.getTabCount());
+
+      if (tabPane.getSelectedIndex() != -1)
+        {
+	  Component visible = getVisibleComponent();
+	  Insets insets = getContentBorderInsets(tabPane.getTabPlacement());
+	  visible.setBounds(contentRect.x + insets.left,
+	                    contentRect.y + insets.top,
+	                    contentRect.width - insets.left - insets.right,
+	                    contentRect.height - insets.top - insets.bottom);
+        }
+    }
+
+    /**
+     * This method calculates the size of the the JTabbedPane.
+     *
+     * @param minimum Whether the JTabbedPane will try to be as small as it
+     *        can.
+     *
+     * @return The desired size of the JTabbedPane.
+     */
+    protected Dimension calculateSize(boolean minimum)
     {
-	JTabbedPane p = (JTabbedPane) c;
+      int tabPlacement = tabPane.getTabPlacement();
+      int width = 0;
+      int height = 0;
+
+      int componentHeight = 0;
+      int componentWidth = 0;
+      Component c;
+      Dimension dims;
+      for (int i = 0; i < tabPane.getTabCount(); i++)
+        {
+	  c = tabPane.getComponentAt(i);
+	  if (c == null)
+	    continue;
+	  calcRect = c.getBounds();
+	  dims = c.getPreferredSize();
+	  if (dims != null)
+	    {
+	      componentHeight = Math.max(componentHeight, dims.height);
+	      componentWidth = Math.max(componentWidth, dims.width);
+	    }
+        }
+      Insets insets = tabPane.getInsets();
+
+      if (tabPlacement == SwingConstants.TOP
+          || tabPlacement == SwingConstants.BOTTOM)
+        {
+	  width = calculateMaxTabWidth(tabPlacement) * tabPane.getTabCount();
+	  calcRect = tabPane.getParent().getBounds();
+	  width = Math.max(width, componentWidth);
+
+	  int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width);
+	  height = tabAreaHeight + componentHeight;
+        }
+      else
+        {
+	  height = calculateMaxTabHeight(tabPlacement) * tabPane.getTabCount();
+	  calcRect = tabPane.getParent().getBounds();
+	  height = Math.max(height, componentHeight);
+
+	  int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height);
+	  width = tabAreaWidth + componentWidth;
+        }
+
+      return new Dimension(width, height);
+    }
+
+    // if tab placement is LEFT OR RIGHT, they share width.
+    // if tab placement is TOP OR BOTTOM, they share height
+    // PRE STEP: finds the default sizes for the labels as well as their locations.
+    // AND where they will be placed within the run system.
+    // 1. calls normalizeTab Runs.
+    // 2. calls rotate tab runs.
+    // 3. pads the tab runs.
+    // 4. pads the selected tab.
+
+    /**
+     * This method is called to calculate the tab rectangles.  This method
+     * will calculate the size and position of all  rectangles (taking into
+     * account which ones should be in which tab run). It will pad them and
+     * normalize them  as necessary.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param tabCount The run the current selection is in.
+     */
+    protected void calculateTabRects(int tabPlacement, int tabCount)
+    {
+      if (tabCount == 0)
+	return;
+      assureRectsCreated(tabCount);
+
+      FontMetrics fm = getFontMetrics();
+      SwingUtilities.calculateInnerArea(tabPane, calcRect);
+      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
+      Insets insets = tabPane.getInsets();
+      int max = 0;
+      int runs = 0;
+      int start = getTabRunIndent(tabPlacement, 1);
+      if (tabPlacement == SwingConstants.TOP
+          || tabPlacement == SwingConstants.BOTTOM)
+        {
+	  int maxHeight = calculateMaxTabHeight(tabPlacement);
+
+	  calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
+	  max = calcRect.width + tabAreaInsets.left + insets.left;
+	  start += tabAreaInsets.left + insets.left;
+	  int width = 0;
+	  int runWidth = start;
+
+	  for (int i = 0; i < tabCount; i++)
+	    {
+	      width = calculateTabWidth(tabPlacement, i, fm);
+
+	      if (runWidth + width > max)
+	        {
+		  runWidth = tabAreaInsets.left + insets.left
+		             + getTabRunIndent(tabPlacement, ++runs);
+		  rects[i] = new Rectangle(runWidth,
+		                           insets.top + tabAreaInsets.top,
+		                           width, maxHeight);
+		  runWidth += width;
+		  if (runs > tabRuns.length - 1)
+		    expandTabRunsArray();
+		  tabRuns[runs] = i;
+	        }
+	      else
+	        {
+		  rects[i] = new Rectangle(runWidth,
+		                           insets.top + tabAreaInsets.top,
+		                           width, maxHeight);
+		  runWidth += width;
+	        }
+	    }
+	  runs++;
+	  tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;
+	  tabAreaRect.height = runs * maxTabHeight
+	                       - (runs - 1) * tabRunOverlay
+	                       + tabAreaInsets.top + tabAreaInsets.bottom;
+	  contentRect.width = tabAreaRect.width;
+	  contentRect.height = tabPane.getHeight() - insets.top
+	                       - insets.bottom - tabAreaRect.height;
+	  contentRect.x = insets.left;
+	  tabAreaRect.x = insets.left;
+	  if (tabPlacement == SwingConstants.BOTTOM)
+	    {
+	      contentRect.y = insets.top;
+	      tabAreaRect.y = contentRect.y + contentRect.height;
+	    }
+	  else
+	    {
+	      tabAreaRect.y = insets.top;
+	      contentRect.y = tabAreaRect.y + tabAreaRect.height;
+	    }
+        }
+      else
+        {
+	  int maxWidth = calculateMaxTabWidth(tabPlacement);
+	  calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
+	  max = calcRect.height + tabAreaInsets.top + insets.top;
+
+	  int height = 0;
+	  start += tabAreaInsets.top + insets.top;
+	  int runHeight = start;
+
+	  int fontHeight = fm.getHeight();
+
+	  for (int i = 0; i < tabCount; i++)
+	    {
+	      height = calculateTabHeight(tabPlacement, i, fontHeight);
+	      if (runHeight + height > max)
+	        {
+		  runHeight = tabAreaInsets.top + insets.top
+		              + getTabRunIndent(tabPlacement, ++runs);
+		  rects[i] = new Rectangle(insets.left + tabAreaInsets.left,
+		                           runHeight, maxWidth, height);
+		  runHeight += height;
+		  if (runs > tabRuns.length - 1)
+		    expandTabRunsArray();
+		  tabRuns[runs] = i;
+	        }
+	      else
+	        {
+		  rects[i] = new Rectangle(insets.left + tabAreaInsets.left,
+		                           runHeight, maxWidth, height);
+		  runHeight += height;
+	        }
+	    }
+	  runs++;
 
-	Dimension d = new Dimension(50,50);
-	
-	for (int i=0;i<p.getTabCount();i++)
+	  tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay
+	                      + tabAreaInsets.left + tabAreaInsets.right;
+	  tabAreaRect.height = tabPane.getHeight() - insets.top
+	                       - insets.bottom;
+	  tabAreaRect.y = insets.top;
+	  contentRect.width = tabPane.getWidth() - insets.left - insets.right
+	                      - tabAreaRect.width;
+	  contentRect.height = tabAreaRect.height;
+	  contentRect.y = insets.top;
+	  if (tabPlacement == SwingConstants.LEFT)
+	    {
+	      tabAreaRect.x = insets.left;
+	      contentRect.x = tabAreaRect.x + tabAreaRect.width;
+	    }
+	  else
 	    {
-		Component comp = p.getComponentAt(i);
-		
-		Dimension pr = comp.getPreferredSize();
+	      contentRect.x = insets.left;
+	      tabAreaRect.x = contentRect.x + contentRect.width;
+	    }
+        }
+      runCount = runs;
+
+      tabRuns[0] = 0;
+      normalizeTabRuns(tabPlacement, tabCount, start, max);
+
+      if (shouldRotateTabRuns(tabPlacement))
+	rotateTabRuns(tabPlacement, selectedRun);
 
-		d.width = Math.max(d.width, comp.getWidth());
-		d.height = Math.max(d.height, comp.getHeight());
+      // Need to pad the runs and move them to the correct location.	
+      for (int i = 0; i < runCount; i++)
+        {
+	  int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;
+	  if (first == tabCount)
+	    first = 0;
+	  int last = lastTabInRun(tabCount, i);
+	  if (shouldPadTabRun(tabPlacement, i))
+	    padTabRun(tabPlacement, first, last, max);
+
+	  // Done padding, now need to move it.
+	  if (tabPlacement == SwingConstants.TOP && i > 0)
+	    {
+	      for (int j = first; j <= last; j++)
+		rects[j].y += (runCount - i) * maxTabHeight
+		+ (runCount - i) * tabRunOverlay;
 	    }
-	
-	Insets i = p.getInsets();
-	
-	d.width  += i.left + i.right;
-	d.height += i.top + i.bottom;
 
-	int height_of_tabs = 25;
+	  if (tabPlacement == SwingConstants.BOTTOM)
+	    {
+	      int height = tabPane.getBounds().height - insets.bottom
+	                   - tabAreaInsets.bottom;
+	      int adjustment;
+	      if (i == 0)
+		adjustment = height - maxTabHeight;
+	      else
+		adjustment = height - (runCount - i + 1) * maxTabHeight
+		             - (runCount - i) * tabRunOverlay;
 
-	d.height += height_of_tabs;
+	      for (int j = first; j <= last; j++)
+		rects[j].y = adjustment;
+	    }
 
-	// FIXME: should be max of panes in p
-	return d;
+	  if (tabPlacement == SwingConstants.LEFT && i > 0)
+	    {
+	      for (int j = first; j <= last; j++)
+		rects[j].x += (runCount - i) * maxTabWidth
+		- (runCount - i) * tabRunOverlay;
+	    }
+
+	  if (tabPlacement == SwingConstants.RIGHT)
+	    {
+	      int width = tabPane.getBounds().width - insets.right
+	                  - tabAreaInsets.right;
+	      int adjustment;
+	      if (i == 0)
+		adjustment = width - maxTabWidth;
+	      else
+		adjustment = width - (runCount - i + 1) * maxTabWidth
+		             + (runCount - i) * tabRunOverlay;
+
+	      for (int j = first; j <= last; j++)
+		rects[j].x = adjustment;
+	    }
+        }
+      padSelectedTab(tabPlacement, tabPane.getSelectedIndex());
     }
-    
 
-    public Rectangle getTabBounds(JTabbedPane pane, int index)
+    /**
+     * This method is called when the JTabbedPane is laid out in
+     * WRAP_TAB_LAYOUT. It calls calculateLayoutInfo to  find the positions
+     * of all its components.
+     *
+     * @param parent The Container to lay out.
+     */
+    public void layoutContainer(Container parent)
     {
-	return null;
+      calculateLayoutInfo();
     }
 
-    public int getTabRunCount(JTabbedPane pane)
+    /**
+     * This method returns the minimum layout size for the given container.
+     *
+     * @param parent The container that is being sized.
+     *
+     * @return The minimum size.
+     */
+    public Dimension minimumLayoutSize(Container parent)
     {
-	return 0;
+      return calculateSize(false);
     }
 
-    public int tabForCoordinate(JTabbedPane pane, int x, int y)
+    // If there is more free space in an adjacent run AND the tab in the run can fit in the 
+    // adjacent run, move it. This method is not perfect, it is merely an approximation.
+    // If you play around with Sun's JTabbedPane, you'll see that 
+    // it does do some pretty strange things with regards to not moving tabs 
+    // that should be moved. 
+    // start = the x position where the tabs will begin
+    // max = the maximum position of where the tabs can go to (tabAreaInsets.left + the width of the tab area)
+
+    /**
+     * This method tries to "even out" the number of tabs in each run based on
+     * their widths.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param tabCount The number of tabs.
+     * @param start The x position where the tabs will begin.
+     * @param max The maximum x position where the tab can run to.
+     */
+    protected void normalizeTabRuns(int tabPlacement, int tabCount, int start,
+                                    int max)
     {
-	return 0;
+      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
+      if (tabPlacement == SwingUtilities.TOP
+          || tabPlacement == SwingUtilities.BOTTOM)
+        {
+	  // We should only do this for runCount - 1, cause we can only shift that many times between
+	  // runs.
+	  for (int i = 1; i < runCount; i++)
+	    {
+	      Rectangle currRun = rects[lastTabInRun(tabCount, i)];
+	      Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
+	      int spaceInCurr = currRun.x + currRun.width;
+	      int spaceInNext = nextRun.x + nextRun.width;
+
+	      int diffNow = spaceInCurr - spaceInNext;
+	      int diffLater = (spaceInCurr - currRun.width)
+	                      - (spaceInNext + currRun.width);
+	      while (Math.abs(diffLater) < Math.abs(diffNow)
+	             && spaceInNext + currRun.width < max)
+	        {
+		  tabRuns[i]--;
+		  spaceInNext += currRun.width;
+		  spaceInCurr -= currRun.width;
+		  currRun = rects[lastTabInRun(tabCount, i)];
+		  diffNow = spaceInCurr - spaceInNext;
+		  diffLater = (spaceInCurr - currRun.width)
+		              - (spaceInNext + currRun.width);
+	        }
+
+	      // Fix the bounds.
+	      int first = lastTabInRun(tabCount, i) + 1;
+	      int last = lastTabInRun(tabCount, getNextTabRun(i));
+	      int currX = tabAreaInsets.left;
+	      for (int j = first; j <= last; j++)
+	        {
+		  rects[j].x = currX;
+		  currX += rects[j].width;
+	        }
+	    }
+        }
+      else
+        {
+	  for (int i = 1; i < runCount; i++)
+	    {
+	      Rectangle currRun = rects[lastTabInRun(tabCount, i)];
+	      Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
+	      int spaceInCurr = currRun.y + currRun.height;
+	      int spaceInNext = nextRun.y + nextRun.height;
+
+	      int diffNow = spaceInCurr - spaceInNext;
+	      int diffLater = (spaceInCurr - currRun.height)
+	                      - (spaceInNext + currRun.height);
+	      while (Math.abs(diffLater) < Math.abs(diffNow)
+	             && spaceInNext + currRun.height < max)
+	        {
+		  tabRuns[i]--;
+		  spaceInNext += currRun.height;
+		  spaceInCurr -= currRun.height;
+		  currRun = rects[lastTabInRun(tabCount, i)];
+		  diffNow = spaceInCurr - spaceInNext;
+		  diffLater = (spaceInCurr - currRun.height)
+		              - (spaceInNext + currRun.height);
+	        }
+
+	      int first = lastTabInRun(tabCount, i) + 1;
+	      int last = lastTabInRun(tabCount, getNextTabRun(i));
+	      int currY = tabAreaInsets.top;
+	      for (int j = first; j <= last; j++)
+	        {
+		  rects[j].y = currY;
+		  currY += rects[j].height;
+	        }
+	    }
+        }
+    }
+
+    /**
+     * This method pads the tab at the selected index by the  selected tab pad
+     * insets (so that it looks larger).
+     *
+     * @param tabPlacement The placement of the tabs.
+     * @param selectedIndex The selected index.
+     */
+    protected void padSelectedTab(int tabPlacement, int selectedIndex)
+    {
+      Insets insets = getSelectedTabPadInsets(tabPlacement);
+      rects[selectedIndex].x -= insets.left;
+      rects[selectedIndex].y -= insets.top;
+      rects[selectedIndex].width += insets.left + insets.right;
+      rects[selectedIndex].height += insets.top + insets.bottom;
+    }
+
+    // If the tabs on the run don't fill the width of the window, make it fit now.
+    // start = starting index of the run
+    // end = last index of the run
+    // max = tabAreaInsets.left + width (or equivalent)
+    // assert start <= end.
+
+    /**
+     * This method makes each tab in the run larger so that the  tabs expand
+     * to fill the runs width/height (depending on tabPlacement).
+     *
+     * @param tabPlacement The placement of the tabs.
+     * @param start The index of the first tab.
+     * @param end The last index of the tab
+     * @param max The amount of space in the run (width for TOP and BOTTOM
+     *        tabPlacement).
+     */
+    protected void padTabRun(int tabPlacement, int start, int end, int max)
+    {
+      if (tabPlacement == SwingConstants.TOP
+          || tabPlacement == SwingConstants.BOTTOM)
+        {
+	  int runWidth = rects[end].x + rects[end].width;
+	  int spaceRemaining = max - runWidth;
+	  int numTabs = end - start + 1;
+
+	  // now divvy up the space.
+	  int spaceAllocated = spaceRemaining / numTabs;
+	  int currX = rects[start].x;
+	  for (int i = start; i <= end; i++)
+	    {
+	      rects[i].x = currX;
+	      rects[i].width += spaceAllocated;
+	      currX += rects[i].width;
+	      // This is used because since the spaceAllocated 
+	      // variable is an int, it rounds down. Sometimes,
+	      // we don't fill an entire row, so we make it do
+	      // so now.
+	      if (i == end && rects[i].x + rects[i].width != max)
+		rects[i].width = max - rects[i].x;
+	    }
+        }
+      else
+        {
+	  int runHeight = rects[end].y + rects[end].height;
+	  int spaceRemaining = max - runHeight;
+	  int numTabs = end - start + 1;
+
+	  int spaceAllocated = spaceRemaining / numTabs;
+	  int currY = rects[start].y;
+	  for (int i = start; i <= end; i++)
+	    {
+	      rects[i].y = currY;
+	      rects[i].height += spaceAllocated;
+	      currY += rects[i].height;
+	      if (i == end && rects[i].y + rects[i].height != max)
+		rects[i].height = max - rects[i].y;
+	    }
+        }
+    }
+
+    /**
+     * This method returns the preferred layout size for the given container.
+     *
+     * @param parent The container to size.
+     *
+     * @return The preferred layout size.
+     */
+    public Dimension preferredLayoutSize(Container parent)
+    {
+      return calculateSize(false);
     }
+
+    /**
+     * This method returns the preferred tab height given a tabPlacement and
+     * width.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param width The expected width.
+     *
+     * @return The preferred tab area height.
+     */
+    protected int preferredTabAreaHeight(int tabPlacement, int width)
+    {
+      if (tabPane.getTabCount() == 0)
+	return calculateTabAreaHeight(tabPlacement, 0, 0);
+
+      int runs = 0;
+      int runWidth = 0;
+      int tabWidth = 0;
+
+      FontMetrics fm = getFontMetrics();
+
+      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
+      Insets insets = tabPane.getInsets();
+
+      // Only interested in width, this is a messed up rectangle now.
+      width -= tabAreaInsets.left + tabAreaInsets.right + insets.left
+      + insets.right;
+
+      // The reason why we can't use runCount:
+      // This method is only called to calculate the size request
+      // for the tabbedPane. However, this size request is dependent on 
+      // our desired width. We need to find out what the height would
+      // be IF we got our desired width.
+      for (int i = 0; i < tabPane.getTabCount(); i++)
+        {
+	  tabWidth = calculateTabWidth(tabPlacement, i, fm);
+	  if (runWidth + tabWidth > width)
+	    {
+	      runWidth = tabWidth;
+	      runs++;
+	    }
+	  else
+	    runWidth += tabWidth;
+        }
+      runs++;
+
+      int maxTabHeight = calculateMaxTabHeight(tabPlacement);
+      int tabAreaHeight = calculateTabAreaHeight(tabPlacement, runs,
+                                                 maxTabHeight);
+      return tabAreaHeight;
+    }
+
+    /**
+     * This method calculates the preferred tab area width given a tab
+     * placement and height.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param height The expected height.
+     *
+     * @return The preferred tab area width.
+     */
+    protected int preferredTabAreaWidth(int tabPlacement, int height)
+    {
+      if (tabPane.getTabCount() == 0)
+	return calculateTabAreaHeight(tabPlacement, 0, 0);
+
+      int runs = 0;
+      int runHeight = 0;
+      int tabHeight = 0;
+
+      FontMetrics fm = getFontMetrics();
+
+      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
+      Insets insets = tabPane.getInsets();
+
+      height -= tabAreaInsets.top + tabAreaInsets.bottom + insets.top
+      + insets.bottom;
+      int fontHeight = fm.getHeight();
+
+      for (int i = 0; i < tabPane.getTabCount(); i++)
+        {
+	  tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);
+	  if (runHeight + tabHeight > height)
+	    {
+	      runHeight = tabHeight;
+	      runs++;
+	    }
+	  else
+	    runHeight += tabHeight;
+        }
+      runs++;
+
+      int maxTabWidth = calculateMaxTabWidth(tabPlacement);
+      int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runs, maxTabWidth);
+      return tabAreaWidth;
+    }
+
+    /**
+     * This method rotates the places each run in the correct place  the
+     * tabRuns array. See the comment for tabRuns for how the runs are placed
+     * in the array.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param selectedRun The run the current selection is in.
+     */
+    protected void rotateTabRuns(int tabPlacement, int selectedRun)
+    {
+      if (selectedRun == 1 || selectedRun == -1)
+	return;
+      int[] newTabRuns = new int[tabRuns.length];
+      int currentRun = selectedRun;
+      int i = 1;
+      do
+        {
+	  newTabRuns[i] = tabRuns[currentRun];
+	  currentRun = getNextTabRun(currentRun);
+	  i++;
+        }
+      while (i < runCount);
+      if (runCount > 1)
+	newTabRuns[0] = tabRuns[currentRun];
+
+      tabRuns = newTabRuns;
+      BasicTabbedPaneUI.this.selectedRun = 1;
+    }
+
+    /**
+     * This method is called when a component is removed  from the
+     * JTabbedPane.
+     *
+     * @param comp The component removed.
+     */
+    public void removeLayoutComponent(Component comp)
+    {
+      // Do nothing.
+    }
+  }
+
+  /**
+   * This class acts as the LayoutManager for the JTabbedPane in
+   * SCROLL_TAB_MODE.
+   */
+  private class TabbedPaneScrollLayout extends TabbedPaneLayout
+  {
+    /**
+     * This method returns the preferred layout size for the given container.
+     *
+     * @param parent The container to calculate a size for.
+     *
+     * @return The preferred layout size.
+     */
+    public Dimension preferredLayoutSize(Container parent)
+    {
+      return super.calculateSize(true);
+    }
+
+    /**
+     * This method returns the minimum layout size for the given container.
+     *
+     * @param parent The container to calculate a size for.
+     *
+     * @return The minimum layout size.
+     */
+    public Dimension minimumLayoutSize(Container parent)
+    {
+      return super.calculateSize(true);
+    }
+
+    /**
+     * This method calculates the tab area height given  a desired width.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param width The expected width.
+     *
+     * @return The tab area height given the width.
+     */
+    protected int preferredTabAreaHeight(int tabPlacement, int width)
+    {
+      if (tabPane.getTabCount() == 0)
+	return calculateTabAreaHeight(tabPlacement, 0, 0);
+
+      int runs = 1;
+
+      int maxTabHeight = calculateMaxTabHeight(tabPlacement);
+      int tabAreaHeight = calculateTabAreaHeight(tabPlacement, runs,
+                                                 maxTabHeight);
+      return tabAreaHeight;
+    }
+
+    /**
+     * This method calculates the tab area width given a desired height.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param height The expected height.
+     *
+     * @return The tab area width given the height.
+     */
+    protected int preferredTabAreaWidth(int tabPlacement, int height)
+    {
+      if (tabPane.getTabCount() == 0)
+	return calculateTabAreaHeight(tabPlacement, 0, 0);
+
+      int runs = 1;
+
+      int maxTabWidth = calculateMaxTabWidth(tabPlacement);
+      int tabAreaWidth = calculateTabAreaWidth(tabPlacement, runs, maxTabWidth);
+      return tabAreaWidth;
+    }
+
+    /**
+     * This method is called to calculate the tab rectangles.  This method
+     * will calculate the size and position of all  rectangles (taking into
+     * account which ones should be in which tab run). It will pad them and
+     * normalize them  as necessary.
+     *
+     * @param tabPlacement The JTabbedPane's tab placement.
+     * @param tabCount The number of tabs.
+     */
+    protected void calculateTabRects(int tabPlacement, int tabCount)
+    {
+      if (tabCount == 0)
+	return;
+      assureRectsCreated(tabCount);
+
+      FontMetrics fm = getFontMetrics();
+      SwingUtilities.calculateInnerArea(tabPane, calcRect);
+      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);
+      Insets insets = tabPane.getInsets();
+      int max = 0;
+      int runs = 1;
+      int start = 0;
+      int top = 0;
+      if (tabPlacement == SwingConstants.TOP
+          || tabPlacement == SwingConstants.BOTTOM)
+        {
+	  int maxHeight = calculateMaxTabHeight(tabPlacement);
+	  calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
+	  max = calcRect.width + tabAreaInsets.left + insets.left;
+	  start = tabAreaInsets.left + insets.left;
+	  int width = 0;
+	  int runWidth = start;
+	  top = insets.top + tabAreaInsets.top;
+	  for (int i = 0; i < tabCount; i++)
+	    {
+	      width = calculateTabWidth(tabPlacement, i, fm);
+
+	      rects[i] = new Rectangle(runWidth, top, width, maxHeight);
+	      runWidth += width;
+	    }
+	  tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;
+	  tabAreaRect.height = runs * maxTabHeight
+	                       - (runs - 1) * tabRunOverlay
+	                       + tabAreaInsets.top + tabAreaInsets.bottom;
+	  contentRect.width = tabAreaRect.width;
+	  contentRect.height = tabPane.getHeight() - insets.top
+	                       - insets.bottom - tabAreaRect.height;
+	  contentRect.x = insets.left;
+	  tabAreaRect.x = insets.left;
+	  if (tabPlacement == SwingConstants.BOTTOM)
+	    {
+	      contentRect.y = insets.top;
+	      tabAreaRect.y = contentRect.y + contentRect.height;
+	    }
+	  else
+	    {
+	      tabAreaRect.y = insets.top;
+	      contentRect.y = tabAreaRect.y + tabAreaRect.height;
+	    }
+        }
+      else
+        {
+	  int maxWidth = calculateMaxTabWidth(tabPlacement);
+
+	  calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
+	  max = calcRect.height + tabAreaInsets.top;
+	  int height = 0;
+	  start = tabAreaInsets.top + insets.top;
+	  int runHeight = start;
+	  int fontHeight = fm.getHeight();
+	  top = insets.left + tabAreaInsets.left;
+	  for (int i = 0; i < tabCount; i++)
+	    {
+	      height = calculateTabHeight(tabPlacement, i, fontHeight);
+	      rects[i] = new Rectangle(top, runHeight, maxWidth, height);
+	      runHeight += height;
+	    }
+	  tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay
+	                      + tabAreaInsets.left + tabAreaInsets.right;
+	  tabAreaRect.height = tabPane.getHeight() - insets.top
+	                       - insets.bottom;
+	  tabAreaRect.y = insets.top;
+	  contentRect.width = tabPane.getWidth() - insets.left - insets.right
+	                      - tabAreaRect.width;
+	  contentRect.height = tabAreaRect.height;
+	  contentRect.y = insets.top;
+	  if (tabPlacement == SwingConstants.LEFT)
+	    {
+	      tabAreaRect.x = insets.left;
+	      contentRect.x = tabAreaRect.x + tabAreaRect.width;
+	    }
+	  else
+	    {
+	      contentRect.x = insets.left;
+	      tabAreaRect.x = contentRect.x + contentRect.width;
+	    }
+        }
+      runCount = runs;
+
+      padSelectedTab(tabPlacement, tabPane.getSelectedIndex());
+    }
+
+    /**
+     * This method is called when the JTabbedPane is laid out in
+     * SCROLL_TAB_LAYOUT. It finds the position for all components in the
+     * JTabbedPane.
+     *
+     * @param pane The JTabbedPane to be laid out.
+     */
+    public void layoutContainer(Container pane)
+    {
+      super.layoutContainer(pane);
+      int tabCount = tabPane.getTabCount();
+      if (tabCount == 0)
+	return;
+      int tabPlacement = tabPane.getTabPlacement();
+      incrButton.hide();
+      decrButton.hide();
+      if (tabPlacement == SwingConstants.TOP
+          || tabPlacement == SwingConstants.BOTTOM)
+        {
+	  if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x
+	      + rects[tabCount - 1].width)
+	    {
+	      Dimension incrDims = incrButton.getPreferredSize();
+	      Dimension decrDims = decrButton.getPreferredSize();
+
+	      decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+	                           - incrDims.width - decrDims.width,
+	                           tabAreaRect.y, decrDims.width,
+	                           tabAreaRect.height);
+	      incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
+	                           - incrDims.width, tabAreaRect.y,
+	                           decrDims.width, tabAreaRect.height);
+
+	      tabAreaRect.width -= decrDims.width + incrDims.width;
+	      incrButton.show();
+	      decrButton.show();
+	    }
+        }
+
+      if (tabPlacement == SwingConstants.LEFT
+          || tabPlacement == SwingConstants.RIGHT)
+        {
+	  if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y
+	      + rects[tabCount - 1].height)
+	    {
+	      Dimension incrDims = incrButton.getPreferredSize();
+	      Dimension decrDims = decrButton.getPreferredSize();
+
+	      decrButton.setBounds(tabAreaRect.x,
+	                           tabAreaRect.y + tabAreaRect.height
+	                           - incrDims.height - decrDims.height,
+	                           tabAreaRect.width, decrDims.height);
+	      incrButton.setBounds(tabAreaRect.x,
+	                           tabAreaRect.y + tabAreaRect.height
+	                           - incrDims.height, tabAreaRect.width,
+	                           incrDims.height);
+
+	      tabAreaRect.height -= decrDims.height + incrDims.height;
+	      incrButton.show();
+	      decrButton.show();
+	    }
+        }
+      viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width,
+                         tabAreaRect.height);
+      int tabC = tabPane.getTabCount() - 1;
+      if (tabCount > 0)
+        {
+	  int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);
+	  int h = Math.max(rects[tabC].height, tabAreaRect.height);
+	  Point p = findPointForIndex(currentScrollLocation);
+
+	  // we want to cover that entire space so that borders that run under
+	  // the tab area don't show up when we move the viewport around.
+	  System.out.println("Setting bounds in layout container");
+	  panel.setBounds(0, 0, w + p.x, h + p.y);
+	  System.out.println("done setting bounds in layout container");
+        }
+      viewport.setViewPosition(findPointForIndex(currentScrollLocation));
+    }
+  }
+
+  /**
+   * This class handles ChangeEvents from the JTabbedPane.
+   */
+  protected class TabSelectionHandler implements ChangeListener
+  {
+    /**
+     * This method is called whenever a ChangeEvent is fired from the
+     * JTabbedPane.
+     *
+     * @param e The ChangeEvent fired.
+     */
+    public void stateChanged(ChangeEvent e)
+    {
+      selectedRun = getRunForTab(tabPane.getTabCount(),
+                                 tabPane.getSelectedIndex());
+      tabPane.layout();
+      tabPane.repaint();
+    }
+  }
+
+  /**
+   * This helper class is a JPanel that fits inside the ScrollViewport. This
+   * panel's sole job is to paint the tab rectangles inside the  viewport so
+   * that it's clipped correctly.
+   */
+  private class ScrollingPanel extends JPanel
+  {
+    /**
+     * This is a private UI class for our panel.
+     */
+    private class ScrollingPanelUI extends BasicPanelUI
+    {
+      /**
+       * This method overrides the default paint method. It paints the tab
+       * rectangles for the JTabbedPane in the panel.
+       *
+       * @param g The Graphics object to paint with.
+       * @param c The JComponent to paint.
+       */
+      public void paint(Graphics g, JComponent c)
+      {
+	paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
+      }
+    }
+
+    /**
+     * This method overrides the updateUI method. It makes the default UI for
+     * this ScrollingPanel to be  a ScrollingPanelUI.
+     */
+    public void updateUI()
+    {
+      setUI((PanelUI) new ScrollingPanelUI());
+    }
+  }
+
+  /**
+   * This is a helper class that paints the panel that paints tabs. This
+   * custom JViewport is used so that the tabs painted in the panel will be
+   * clipped. This class implements UIResource so tabs are not added when
+   * this objects of this class are added to the  JTabbedPane.
+   */
+  private class ScrollingViewport extends JViewport implements UIResource
+  {
+    /**
+     * This method is temporary until the viewport layouts are  implemented.
+     * Need it because the flow layout it  currently moves our panel around.
+     *
+     * @param g The graphics object to paint with.
+     */
+    public void paint(Graphics g)
+    {
+      // FIXME: Remove this as well.
+      int tabC = tabPane.getTabCount() - 1;
+      if (tabC + 1 > 0)
+        {
+	  int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);
+	  int h = Math.max(rects[tabC].height, tabAreaRect.height);
+	  Point p = findPointForIndex(currentScrollLocation);
+
+	  // we want to cover that entire space so that borders that run under
+	  // the tab area don't show up when we move the viewport around.
+	  System.out.println("Setting bounds in paint");
+
+	  panel.setBounds(0, 0, w + p.x, h + p.y);
+	  System.out.println("Done setting bounds in paint");
+        }
+
+      // FIXME: Remove when ViewportLayout is done.
+      setViewPosition(findPointForIndex(currentScrollLocation));
+      super.paint(g);
+    }
+  }
+
+  /**
+   * This is a helper class that implements UIResource so it is not added as a
+   * tab when an object of this class is added to the JTabbedPane.
+   */
+  private class ScrollingButton extends BasicArrowButton implements UIResource
+  {
+    /**
+     * Creates a ScrollingButton given the direction.
+     *
+     * @param dir The direction to point in.
+     */
+    public ScrollingButton(int dir)
+    {
+      super(dir);
+    }
+  }
+
+  /** The button that increments the current scroll location. */
+  private transient ScrollingButton incrButton;
+
+  /** The button that decrements the current scroll location. */
+  private transient ScrollingButton decrButton;
+
+  /** The viewport used to display the tabs. */
+  private transient ScrollingViewport viewport;
+
+  /** The panel inside the viewport that paints the tabs. */
+  private transient ScrollingPanel panel;
+
+  /** The starting visible tab in the run in SCROLL_TAB_MODE. */
+  private transient int currentScrollLocation;
+
+  /** A reusable rectangle. */
+  protected Rectangle calcRect;
+
+  /** An array of Rectangles keeping track of the tabs' area and position. */
+  protected Rectangle[] rects;
+
+  /** The insets around the content area. */
+  protected Insets contentBorderInsets;
+
+  /** The extra insets around the selected tab. */
+  protected Insets selectedTabPadInsets;
+
+  /** The insets around the tab area. */
+  protected Insets tabAreaInsets;
+
+  /** The insets around each and every tab. */
+  protected Insets tabInsets;
+
+  /**
+   * The outer bottom and right edge color for both the tab and content
+   * border.
+   */
+  protected Color darkShadow;
+
+  /** The color of the focus outline on the selected tab. */
+  protected Color focus;
+
+  /** FIXME: find a use for this. */
+  protected Color highlight;
+
+  /** The top and left edge color for both the tab and content border. */
+  protected Color lightHighlight;
+
+  /** The inner bottom and right edge color for the tab and content border. */
+  protected Color shadow;
+
+  /** The maximum tab height. */
+  protected int maxTabHeight;
+
+  /** The maximum tab width. */
+  protected int maxTabWidth;
+
+  /** The number of runs in the JTabbedPane. */
+  protected int runCount;
+
+  /** The index of the run that the selected index is in. */
+  protected int selectedRun;
+
+  /** The amount of space each run overlaps the previous by. */
+  protected int tabRunOverlay;
+
+  /** The gap between text and label */
+  protected int textIconGap;
+
+  // Keeps track of tab runs.
+  // The organization of this array is as follows (lots of experimentation to
+  // figure this out)
+  // index 0 = furthest away from the component area (aka outer run)
+  // index 1 = closest to component area (aka selected run)
+  // index > 1 = listed in order leading from selected run to outer run.
+  // each int in the array is the tab index + 1 (counting starts at 1)
+  // for the last tab in the run. (same as the rects array)
+
+  /** This array keeps track of which tabs are in which run. See above. */
+  protected int[] tabRuns;
+
+  /** Deprecated. This is the keystroke for moving down. */
+  protected KeyStroke downKey;
+
+  /** Deprecated. This is the keystroke for moving left. */
+  protected KeyStroke leftKey;
+
+  /** Deprecated. This is the keystroke for moving right. */
+  protected KeyStroke rightKey;
+
+  /** Deprecated. This is the keystroke for moving up. */
+  protected KeyStroke upKey;
+
+  /** The listener that listens for focus events. */
+  protected FocusListener focusListener;
+
+  /** The listener that listens for mouse events. */
+  protected MouseListener mouseListener;
+
+  /** The listener that listens for property change events. */
+  protected PropertyChangeListener propertyChangeListener;
+
+  /** The listener that listens for change events. */
+  protected ChangeListener tabChangeListener;
+
+  /** The tab pane that this UI paints. */
+  protected JTabbedPane tabPane;
+
+  /** The current layout manager for the tabPane. */
+  private transient LayoutManager layoutManager;
+
+  /** The rectangle that describes the tab area's position and size. */
+  private transient Rectangle tabAreaRect;
+
+  /** The rectangle that describes the content area's position and size. */
+  private transient Rectangle contentRect;
+
+  /**
+   * Creates a new BasicTabbedPaneUI object.
+   */
+  public BasicTabbedPaneUI()
+  {
+    super();
+  }
+
+  /**
+   * This method creates a ScrollingButton that  points in the appropriate
+   * direction for an increasing button.
+   *
+   * @return The increase ScrollingButton.
+   */
+  private ScrollingButton createIncreaseButton()
+  {
+    if (incrButton == null)
+      incrButton = new ScrollingButton(SwingConstants.NORTH);
+    if (tabPane.getTabPlacement() == SwingConstants.TOP
+        || tabPane.getTabPlacement() == SwingConstants.BOTTOM)
+      incrButton.setDirection(SwingConstants.EAST);
+    else
+      incrButton.setDirection(SwingConstants.SOUTH);
+    return incrButton;
+  }
+
+  /**
+   * This method creates a ScrollingButton that points in the appropriate
+   * direction for a decreasing button.
+   *
+   * @return The decrease ScrollingButton.
+   */
+  private ScrollingButton createDecreaseButton()
+  {
+    if (decrButton == null)
+      decrButton = new ScrollingButton(SwingConstants.SOUTH);
+    if (tabPane.getTabPlacement() == SwingConstants.TOP
+        || tabPane.getTabPlacement() == SwingConstants.BOTTOM)
+      decrButton.setDirection(SwingConstants.WEST);
+    else
+      decrButton.setDirection(SwingConstants.NORTH);
+    return decrButton;
+  }
+
+  /**
+   * This method finds the point to set the view  position at given the index
+   * of a tab. The tab will be the first visible tab in the run.
+   *
+   * @param index The index of the first visible tab.
+   *
+   * @return The position of the first visible tab.
+   */
+  private Point findPointForIndex(int index)
+  {
+    int tabPlacement = tabPane.getTabPlacement();
+    int selectedIndex = tabPane.getSelectedIndex();
+    Insets insets = getSelectedTabPadInsets(tabPlacement);
+    int w = 0;
+    int h = 0;
+
+    if (tabPlacement == TOP || tabPlacement == BOTTOM)
+      {
+	if (index > 0)
+	  {
+	    w += rects[index - 1].x + rects[index - 1].width;
+	    if (index > selectedIndex)
+	      w -= insets.left + insets.right;
+	  }
+      }
+
+    else
+      {
+	if (index > 0)
+	  {
+	    h += rects[index - 1].y + rects[index - 1].height;
+	    if (index > selectedIndex)
+	      h -= insets.top + insets.bottom;
+	  }
+      }
+
+    Point p = new Point(w, h);
+    return p;
+  }
+
+  /**
+   * This method creates a new BasicTabbedPaneUI.
+   *
+   * @param c The JComponent to create a UI for.
+   *
+   * @return A new BasicTabbedPaneUI.
+   */
+  public static ComponentUI createUI(JComponent c)
+  {
+    return new BasicTabbedPaneUI();
+  }
+
+  /**
+   * This method installs the UI for the given JComponent.
+   *
+   * @param c The JComponent to install the UI for.
+   */
+  public void installUI(JComponent c)
+  {
+    super.installUI(c);
+    if (c instanceof JTabbedPane)
+      {
+	tabPane = (JTabbedPane) c;
+
+	installComponents();
+	installDefaults();
+	installListeners();
+	installKeyboardActions();
+
+	layoutManager = createLayoutManager();
+	tabPane.setLayout(layoutManager);
+	tabPane.layout();
+      }
+  }
+
+  /**
+   * This method uninstalls the UI for the  given JComponent.
+   *
+   * @param c The JComponent to uninstall the UI for.
+   */
+  public void uninstallUI(JComponent c)
+  {
+    layoutManager = null;
+
+    uninstallKeyboardActions();
+    uninstallListeners();
+    uninstallDefaults();
+    uninstallComponents();
+
+    tabPane = null;
+  }
+
+  /**
+   * This method creates the appropriate layout manager for the JTabbedPane's
+   * current tab layout policy. If the tab layout policy is
+   * SCROLL_TAB_LAYOUT, then all the associated components that need to be
+   * created will be done so now.
+   *
+   * @return A layout manager given the tab layout policy.
+   */
+  public LayoutManager createLayoutManager()
+  {
+    if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
+      return new TabbedPaneLayout();
+    else
+      {
+	incrButton = createIncreaseButton();
+	decrButton = createDecreaseButton();
+	viewport = new ScrollingViewport();
+	panel = new ScrollingPanel();
+	viewport.setView(panel);
+	tabPane.add(incrButton);
+	tabPane.add(decrButton);
+	tabPane.add(viewport);
+	currentScrollLocation = 0;
+	decrButton.setEnabled(false);
+	panel.addMouseListener(mouseListener);
+	incrButton.addMouseListener(mouseListener);
+	decrButton.addMouseListener(mouseListener);
+	viewport.setBackground(Color.LIGHT_GRAY);
+
+	return new TabbedPaneScrollLayout();
+      }
+  }
+
+  /**
+   * This method installs components for this JTabbedPane.
+   */
+  protected void installComponents()
+  {
+    // Nothing to be done.
+  }
+
+  /**
+   * This method uninstalls components for this JTabbedPane.
+   */
+  protected void uninstallComponents()
+  {
+    // Nothing to be done.
+  }
+
+  /**
+   * This method installs defaults for the Look and Feel.
+   */
+  protected void installDefaults()
+  {
+    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+    tabPane.setFont(defaults.getFont("TabbedPane.font"));
+    tabPane.setForeground(defaults.getColor("TabbedPane.foreground"));
+    tabPane.setBackground(defaults.getColor("TabbedPane.background"));
+
+    highlight = defaults.getColor("TabbedPane.highlight");
+    lightHighlight = defaults.getColor("TabbedPane.lightHighlight");
+
+    shadow = defaults.getColor("TabbedPane.shadow");
+    darkShadow = defaults.getColor("TabbedPane.darkShadow");
+
+    focus = defaults.getColor("TabbedPane.focus");
+
+    textIconGap = defaults.getInt("TabbedPane.textIconGap");
+    tabRunOverlay = defaults.getInt("TabbedPane.tabRunOverlay");
+
+    tabInsets = defaults.getInsets("TabbedPane.tabbedPaneTabInsets");
+    selectedTabPadInsets = defaults.getInsets("TabbedPane.tabbedPaneTabPadInsets");
+    tabAreaInsets = defaults.getInsets("TabbedPane.tabbedPaneTabAreaInsets");
+    contentBorderInsets = defaults.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
+
+    calcRect = new Rectangle();
+    tabRuns = new int[10];
+    tabAreaRect = new Rectangle();
+    contentRect = new Rectangle();
+  }
+
+  /**
+   * This method uninstalls defaults for the Look and Feel.
+   */
+  protected void uninstallDefaults()
+  {
+    calcRect = null;
+    tabAreaRect = null;
+    contentRect = null;
+    tabRuns = null;
+
+    contentBorderInsets = null;
+    tabAreaInsets = null;
+    selectedTabPadInsets = null;
+    tabInsets = null;
+
+    focus = null;
+    darkShadow = null;
+    shadow = null;
+    lightHighlight = null;
+    highlight = null;
+
+    tabPane.setBackground(null);
+    tabPane.setForeground(null);
+    tabPane.setFont(null);
+  }
+
+  /**
+   * This method creates and installs the listeners for this UI.
+   */
+  protected void installListeners()
+  {
+    mouseListener = createMouseListener();
+    tabChangeListener = createChangeListener();
+    propertyChangeListener = createPropertyChangeListener();
+    focusListener = createFocusListener();
+
+    tabPane.addMouseListener(mouseListener);
+    tabPane.addChangeListener(tabChangeListener);
+    tabPane.addPropertyChangeListener(propertyChangeListener);
+    tabPane.addFocusListener(focusListener);
+  }
+
+  /**
+   * This method removes and nulls the listeners for this UI.
+   */
+  protected void uninstallListeners()
+  {
+    tabPane.removeFocusListener(focusListener);
+    tabPane.removePropertyChangeListener(propertyChangeListener);
+    tabPane.removeChangeListener(tabChangeListener);
+    tabPane.removeMouseListener(mouseListener);
+
+    focusListener = null;
+    propertyChangeListener = null;
+    tabChangeListener = null;
+    mouseListener = null;
+  }
+
+  /**
+   * This method creates a new MouseListener.
+   *
+   * @return A new MouseListener.
+   */
+  protected MouseListener createMouseListener()
+  {
+    return new MouseHandler();
+  }
+
+  /**
+   * This method creates a new FocusListener.
+   *
+   * @return A new FocusListener.
+   */
+  protected FocusListener createFocusListener()
+  {
+    return new FocusHandler();
+  }
+
+  /**
+   * This method creates a new ChangeListener.
+   *
+   * @return A new ChangeListener.
+   */
+  protected ChangeListener createChangeListener()
+  {
+    return new TabSelectionHandler();
+  }
+
+  /**
+   * This method creates a new PropertyChangeListener.
+   *
+   * @return A new PropertyChangeListener.
+   */
+  protected PropertyChangeListener createPropertyChangeListener()
+  {
+    return new PropertyChangeHandler();
+  }
+
+  /**
+   * This method installs keyboard actions for the JTabbedPane.
+   */
+  protected void installKeyboardActions()
+  {
+    // FIXME: Implement.
+  }
+
+  /**
+   * This method uninstalls keyboard actions for the JTabbedPane.
+   */
+  protected void uninstallKeyboardActions()
+  {
+    // FIXME: Implement.
+  }
+
+  /**
+   * This method returns the preferred size of the JTabbedPane.
+   *
+   * @param c The JComponent to find a size for.
+   *
+   * @return The preferred size.
+   */
+  public Dimension getPreferredSize(JComponent c)
+  {
+    return layoutManager.preferredLayoutSize(tabPane);
+  }
+
+  /**
+   * This method returns the minimum size of the JTabbedPane.
+   *
+   * @param c The JComponent to find a size for.
+   *
+   * @return The minimum size.
+   */
+  public Dimension getMinimumSize(JComponent c)
+  {
+    return layoutManager.minimumLayoutSize(tabPane);
+  }
+
+  /**
+   * This method returns the maximum size of the JTabbedPane.
+   *
+   * @param c The JComponent to find a size for.
+   *
+   * @return The maximum size.
+   */
+  public Dimension getMaximumSize(JComponent c)
+  {
+    return getPreferredSize(c);
+  }
+
+  /**
+   * This method paints the JTabbedPane.
+   *
+   * @param g The Graphics object to paint with.
+   * @param c The JComponent to paint.
+   */
+  public void paint(Graphics g, JComponent c)
+  {
+    if (tabPane.getTabCount() == 0)
+      return;
+    if (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
+      paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
+    paintContentBorder(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
+  }
+
+  /**
+   * This method paints the tab area. This includes painting the rectangles
+   * that make up the tabs.
+   *
+   * @param g The Graphics object to paint with.
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param selectedIndex The selected index.
+   */
+  protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
+  {
+    Rectangle ir = new Rectangle();
+    Rectangle tr = new Rectangle();
+
+    // Please note: the ordering of the painting is important. 
+    // we WANT to paint the outermost run first and then work our way in.
+    int tabCount = tabPane.getTabCount();
+    int currRun = 1;
+    if (tabCount < 1)
+      return;
+
+    if (runCount > 1)
+      currRun = 0;
+    for (int i = 0; i < runCount; i++)
+      {
+	int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;
+	if (first == tabCount)
+	  first = 0;
+	int last = lastTabInRun(tabCount, currRun);
+	for (int j = first; j <= last; j++)
+	  {
+	    if (j != selectedIndex)
+	      paintTab(g, tabPlacement, rects, j, ir, tr);
+	  }
+	currRun = getNextTabRun(currRun);
+      }
+    paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
+  }
+
+  /**
+   * This method paints an individual tab.
+   *
+   * @param g The Graphics object to paint with.
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param rects The array of rectangles that keep the size and position of
+   *        the tabs.
+   * @param tabIndex The tab index to paint.
+   * @param iconRect The rectangle to use for the icon.
+   * @param textRect The rectangle to use for the text.
+   */
+  protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects,
+                          int tabIndex, Rectangle iconRect, Rectangle textRect)
+  {
+    FontMetrics fm = getFontMetrics();
+    Icon icon = getIconForTab(tabIndex);
+    String title = tabPane.getTitleAt(tabIndex);
+    boolean isSelected = tabIndex == tabPane.getSelectedIndex();
+    calcRect = getTabBounds(tabPane, tabIndex);
+
+    int x = calcRect.x;
+    int y = calcRect.y;
+    int w = calcRect.width;
+    int h = calcRect.height;
+    if (getRunForTab(tabPane.getTabCount(), tabIndex) == 1)
+      {
+	Insets insets = getTabAreaInsets(tabPlacement);
+	switch (tabPlacement)
+	  {
+	  case TOP:
+	    h += insets.bottom;
+	    break;
+	  case LEFT:
+	    w += insets.right;
+	    break;
+	  case BOTTOM:
+	    y -= insets.top;
+	    h += insets.top;
+	    break;
+	  case RIGHT:
+	    x -= insets.left;
+	    w += insets.left;
+	    break;
+	  }
+      }
+
+    layoutLabel(tabPlacement, fm, tabIndex, title, icon, calcRect, iconRect,
+                textRect, isSelected);
+    paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
+    paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
+
+    // FIXME: Paint little folding corner and jagged edge clipped tab.
+    if (icon != null)
+      paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
+    if (title == null || ! title.equals(""))
+      paintText(g, tabPlacement, tabPane.getFont(), fm, tabIndex, title,
+                textRect, isSelected);
+  }
+
+  /**
+   * This method lays out the tab and finds the location to paint the  icon
+   * and text.
+   *
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param metrics The font metrics for the font to paint with.
+   * @param tabIndex The tab index to paint.
+   * @param title The string painted.
+   * @param icon The icon painted.
+   * @param tabRect The tab bounds.
+   * @param iconRect The calculated icon bounds.
+   * @param textRect The calculated text bounds.
+   * @param isSelected Whether this tab is selected.
+   */
+  protected void layoutLabel(int tabPlacement, FontMetrics metrics,
+                             int tabIndex, String title, Icon icon,
+                             Rectangle tabRect, Rectangle iconRect,
+                             Rectangle textRect, boolean isSelected)
+  {
+    SwingUtilities.layoutCompoundLabel(metrics, title, icon,
+                                       SwingConstants.CENTER,
+                                       SwingConstants.CENTER,
+                                       SwingConstants.CENTER,
+                                       SwingConstants.CENTER, tabRect,
+                                       iconRect, textRect, textIconGap);
+
+    int shiftX = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
+    int shiftY = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
+
+    iconRect.x += shiftX;
+    iconRect.y += shiftY;
+
+    textRect.x += shiftX;
+    textRect.y += shiftY;
+  }
+
+  /**
+   * This method paints the icon.
+   *
+   * @param g The Graphics object to paint.
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param tabIndex The tab index to paint.
+   * @param icon The icon to paint.
+   * @param iconRect The bounds of the icon.
+   * @param isSelected Whether this tab is selected.
+   */
+  protected void paintIcon(Graphics g, int tabPlacement, int tabIndex,
+                           Icon icon, Rectangle iconRect, boolean isSelected)
+  {
+    icon.paintIcon(tabPane, g, iconRect.x, iconRect.y);
+  }
+
+  /**
+   * This method paints the text for the given tab.
+   *
+   * @param g The Graphics object to paint with.
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param font The font to paint with.
+   * @param metrics The fontmetrics of the given font.
+   * @param tabIndex The tab index.
+   * @param title The string to paint.
+   * @param textRect The bounds of the string.
+   * @param isSelected Whether this tab is selected.
+   */
+  protected void paintText(Graphics g, int tabPlacement, Font font,
+                           FontMetrics metrics, int tabIndex, String title,
+                           Rectangle textRect, boolean isSelected)
+  {
+    View textView = getTextViewForTab(tabIndex);
+    if (textView != null)
+      {
+	textView.paint(g, textRect);
+	return;
+      }
+
+    Color fg = tabPane.getForegroundAt(tabIndex);
+    if (fg == null)
+      fg = tabPane.getForeground();
+    Color bg = tabPane.getBackgroundAt(tabIndex);
+    if (bg == null)
+      bg = tabPane.getBackground();
+
+    Color saved_color = g.getColor();
+    Font f = g.getFont();
+    g.setFont(font);
+
+    if (tabPane.isEnabledAt(tabIndex))
+      {
+	g.setColor(fg);
+
+	int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
+
+	if (mnemIndex != -1)
+	  BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
+	                                               textRect.x,
+	                                               textRect.y
+	                                               + metrics.getAscent());
+	else
+	  g.drawString(title, textRect.x, textRect.y + metrics.getAscent());
+      }
+    else
+      {
+	g.setColor(bg.brighter());
+
+	int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
+
+	if (mnemIndex != -1)
+	  BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
+	                                               textRect.x, textRect.y);
+	else
+	  g.drawString(title, textRect.x, textRect.y);
+
+	g.setColor(bg.darker());
+	if (mnemIndex != -1)
+	  BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
+	                                               textRect.x + 1,
+	                                               textRect.y + 1);
+	else
+	  g.drawString(title, textRect.x + 1, textRect.y + 1);
+      }
+
+    g.setColor(saved_color);
+    g.setFont(f);
+  }
+
+  /**
+   * This method returns how much the label for the tab should shift in the X
+   * direction.
+   *
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param tabIndex The tab index being painted.
+   * @param isSelected Whether this tab is selected.
+   *
+   * @return The amount the label should shift by in the X direction.
+   */
+  protected int getTabLabelShiftX(int tabPlacement, int tabIndex,
+                                  boolean isSelected)
+  {
+    // No reason to shift.
+    return 0;
+  }
+
+  /**
+   * This method returns how much the label for the tab should shift in the Y
+   * direction.
+   *
+   * @param tabPlacement The JTabbedPane's tab placement.
+   * @param tabIndex The tab index being painted.
+   * @param isSelected Whether this tab is selected.
+   *
+   * @return The amount the label should shift by in the Y direction.
+   */
+  protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
+                                  boolean isSelected)
+  {
+    // No reason to shift.
+    return 0;
+  }
+
+  /*