PatchSet 6574 
Date: 2005/05/26 11:10:36
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
resynced with gnu classpath: swing fixes

Members: 
        ChangeLog:1.4101->1.4102 
        libraries/javalib/javax/swing/AbstractButton.java:1.13->1.14 
        libraries/javalib/javax/swing/BoxLayout.java:1.6->1.7 
        libraries/javalib/javax/swing/DefaultListSelectionModel.java:1.6->1.7 
        libraries/javalib/javax/swing/JButton.java:1.3->1.4 
        libraries/javalib/javax/swing/JFileChooser.java:1.4->1.5 
        libraries/javalib/javax/swing/JInternalFrame.java:1.8->1.9 
        libraries/javalib/javax/swing/JLayeredPane.java:1.6->1.7 
        libraries/javalib/javax/swing/JMenuItem.java:1.8->1.9 
        libraries/javalib/javax/swing/JTextArea.java:1.9->1.10 
        libraries/javalib/javax/swing/JViewport.java:1.8->1.9 
        libraries/javalib/javax/swing/SwingUtilities.java:1.13->1.14 
        
libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.12->1.13 
        libraries/javalib/javax/swing/plaf/basic/BasicSplitPaneUI.java:1.4->1.5 
        libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.11->1.12 
        libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java:1.5->1.6 
        libraries/javalib/javax/swing/text/JTextComponent.java:1.17->1.18 
        libraries/javalib/javax/swing/tree/TreePath.java:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4101 kaffe/ChangeLog:1.4102
--- kaffe/ChangeLog:1.4101      Thu May 26 10:24:22 2005
+++ kaffe/ChangeLog     Thu May 26 11:10:36 2005
@@ -2,6 +2,125 @@
 
         Resynced with GNU Classpath.
 
+       2005-05-25  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/AbstractButton.java:
+       (constructor): Removed model creation.
+       * javax/swing/JButton.java:
+       (constructor): Added model creation.
+       * javax/swing/JMenuItem.java:
+       (init): Added model creation.
+
+       2005-05-25  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JLayeredPane.java
+       (static getLayer): Add cast to force a call to the instance method
+       getLayer().
+       (getLayeredPaneAbove): Added and implemented method.
+       * javax/swing/JInternalFrame.java
+       (getLayer): Add cast to force a call to the instance method
+       getLayer() of JLayeredPane.
+
+       2005-05-25  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/plaf/basic/BasicSplitPaneUI.java
+       (paint): Added check to make sure the split pane divider has
+       a valid location.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/text/JTextComponent.java
+       (getPreferredScrollableViewportSize): Implemented this method.
+       (getScrollableUnitIncrement): Implemented this method.
+       (getScrollableBlockIncrement): Implemented this method.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JTextArea.java
+       (getPreferredScrollableViewportSize): Added and implemented
+       new method.
+       (getScrollableUnitIncrement): Added and implemented new
+       method.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JLayeredPane.java
+       (getLayer): Added and implemented new (static) method.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JFileChooser.java
+       (constructor(String, FileSystemView)): Added constructor.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JViewport.java
+       (createLayoutManager): Added and implemented new method.
+       (constructor): Set the LayoutManager that is created by
+       createLayoutManager().
+       * javax/swing/plaf/basic/BasicViewportUI.java
+       (installUI): Removed setLayout(..). This is moved into
+       the constructor of JViewport (as the API docs suggest).
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JViewport.java:
+       (ViewListener): Added and implemented inner class.
+       (createViewListener): Added and implemented new method.
+       (setView): Add and remove ViewListener to/from the view component.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/DefaultListSelectionModel.java
+       (fireValueChanged(boolean)): Added and implemented this method.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/SwingUtilities.java:
+       (getWindowAncestor): Added and implemented this method.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/JFileChooser.java:
+       Fixed the values of several public constant fields.
+
+       2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/plaf/basic/BasicLookAndFeel.java
+       (initComponentDefaults): Uncommented code that has accidentally
+       been commented out.
+
+       2005-05-22  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/BoxLayout.java
+       (maximumLayoutSize): Added checks for overflow. This is necessary
+       because some components have maximumSize of Integer.MAX_VALUE,
+       that would cause an overflow if summed up.
+
+       2005-05-22  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/tree/TreePath.java
+       (getParentPath): Return null if this path only has no parent.
+
+       2005-05-22  Roman Kennke  <[EMAIL PROTECTED]>
+
+        * javax/swing/plaf/basic/BasicTextUI.java:
+        (getMaximumSize): Fixed comment.
+
+       2005-05-22  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/tree/TreePath.java:
+       Reformatted this file in order to match our coding style.
+
+       2005-05-22  Roman Kennke  <[EMAIL PROTECTED]>
+
+       * javax/swing/plaf/basic/BasicTextUI.java
+       (getMaximumSize): Implemented this method.
+
+2005-05-26  Dalibor Topic  <[EMAIL PROTECTED]>
+
+        Resynced with GNU Classpath.
+
        2005-05-25  Audrius Meskauskas  <[EMAIL PROTECTED]>
 
        * org/omg/CORBA/TRANSIENT.java (serialVersionUID): Added 1.4 SVUID.
Index: kaffe/libraries/javalib/javax/swing/AbstractButton.java
diff -u kaffe/libraries/javalib/javax/swing/AbstractButton.java:1.13 
kaffe/libraries/javalib/javax/swing/AbstractButton.java:1.14
--- kaffe/libraries/javalib/javax/swing/AbstractButton.java:1.13        Thu May 
19 00:31:20 2005
+++ kaffe/libraries/javalib/javax/swing/AbstractButton.java     Thu May 26 
11:10:40 2005
@@ -523,14 +523,9 @@
  {
     this.text = text;
     default_icon = icon;
-    model = new DefaultButtonModel();
     actionListener = createActionListener();
     changeListener = createChangeListener();
     itemListener = createItemListener();
-
-    model.addActionListener(actionListener);
-    model.addChangeListener(changeListener);
-    model.addItemListener(itemListener);
 
     horizontalAlignment = CENTER;
     horizontalTextPosition = TRAILING;
Index: kaffe/libraries/javalib/javax/swing/BoxLayout.java
diff -u kaffe/libraries/javalib/javax/swing/BoxLayout.java:1.6 
kaffe/libraries/javalib/javax/swing/BoxLayout.java:1.7
--- kaffe/libraries/javalib/javax/swing/BoxLayout.java:1.6      Sun May 15 
10:13:28 2005
+++ kaffe/libraries/javalib/javax/swing/BoxLayout.java  Thu May 26 11:10:40 2005
@@ -477,6 +477,9 @@
             Component comp = children[index];
             Dimension sz = comp.getMaximumSize();
             x += sz.width;
+            // Check for overflow.
+            if (x < 0)
+              x = Integer.MAX_VALUE;
             y = Math.max(y, sz.height);
           }
       }
@@ -489,6 +492,9 @@
             Component comp = children[index];
             Dimension sz = comp.getMaximumSize();
             y += sz.height;
+            // Check for overflow
+            if (y < 0)
+              y = Integer.MAX_VALUE;
             x = Math.max(x, sz.width);
           }
       } 
Index: kaffe/libraries/javalib/javax/swing/DefaultListSelectionModel.java
diff -u kaffe/libraries/javalib/javax/swing/DefaultListSelectionModel.java:1.6 
kaffe/libraries/javalib/javax/swing/DefaultListSelectionModel.java:1.7
--- kaffe/libraries/javalib/javax/swing/DefaultListSelectionModel.java:1.6      
Sat Jan 22 18:29:05 2005
+++ kaffe/libraries/javalib/javax/swing/DefaultListSelectionModel.java  Thu May 
26 11:10:40 2005
@@ -516,6 +516,24 @@
 
   /**
    * Fires a [EMAIL PROTECTED] ListSelectionEvent} to all the listeners of 
type [EMAIL PROTECTED]
+   * ListSelectionListener} registered with this selection model to
+   * indicate that a series of adjustment has just ended.
+   *
+   * The values of [EMAIL PROTECTED] #getMinSelectionIndex} and
+   * [EMAIL PROTECTED] getMaxSelectionIndex} are used in the [EMAIL PROTECTED] 
ListSelectionEvent}
+   * that gets fired.
+   *
+   * @param isAdjusting <code>true</code> if this is the final change
+   *     in a series of adjustments, <code>false/code> otherwise
+   */
+  protected void fireValueChanged(boolean isAdjusting)
+  {
+    fireValueChanged(getMinSelectionIndex(), getMaxSelectionIndex(),
+                     isAdjusting);
+  }
+
+  /**
+   * Fires a [EMAIL PROTECTED] ListSelectionEvent} to all the listeners of 
type [EMAIL PROTECTED]
    * ListSelectionListener} registered with this selection model.
    *
    * @param firstIndex The low index of the changed range
Index: kaffe/libraries/javalib/javax/swing/JButton.java
diff -u kaffe/libraries/javalib/javax/swing/JButton.java:1.3 
kaffe/libraries/javalib/javax/swing/JButton.java:1.4
--- kaffe/libraries/javalib/javax/swing/JButton.java:1.3        Sun Aug  8 
19:46:03 2004
+++ kaffe/libraries/javalib/javax/swing/JButton.java    Thu May 26 11:10:40 2005
@@ -78,6 +78,7 @@
   public JButton(String text, Icon icon)
   {
     super(text, icon);
+    setModel(new DefaultButtonModel());
   }
 
   public Object[] getSelectedObjects()
Index: kaffe/libraries/javalib/javax/swing/JFileChooser.java
diff -u kaffe/libraries/javalib/javax/swing/JFileChooser.java:1.4 
kaffe/libraries/javalib/javax/swing/JFileChooser.java:1.5
--- kaffe/libraries/javalib/javax/swing/JFileChooser.java:1.4   Sat May 21 
15:13:39 2005
+++ kaffe/libraries/javalib/javax/swing/JFileChooser.java       Thu May 26 
11:10:40 2005
@@ -92,58 +92,73 @@
   public static final String APPROVE_SELECTION = "ApproveSelection";
 
   /** DOCUMENT ME! */
-  public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY = 
"approvebuttonText";
+  public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY =
+    "ApproveButtonTextChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY = 
"approveButtonToolTipText";
+  public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY =
+    "ApproveButtonToolTipTextChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY = 
"approveButtonMnemonic";
+  public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY =
+    "ApproveButtonMnemonicChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY = 
"controlButtonsAreShown";
+  public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY =
+    "ControlButtonsAreShownChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String DIRECTORY_CHANGED_PROPERTY = "directory";
+  public static final String DIRECTORY_CHANGED_PROPERTY = "directoryChanged";
 
   /** DOCUMENT ME! */
-  public static final String SELECTED_FILE_CHANGED_PROPERTY = 
"SelectedFileChangedProperty";
+  public static final String SELECTED_FILE_CHANGED_PROPERTY =
+    "SelectedFilesChangedProperty";
 
   /** DOCUMENT ME! */
   public static final String SELECTED_FILES_CHANGED_PROPERTY = "selectedFiles";
 
   /** DOCUMENT ME! */
-  public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY = 
"multiSelectionEnabled";
+  public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY =
+    "MultiSelectionEnabledChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY = 
"fileSystemView";
+  public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY =
+    "FileSystemViewChanged";
 
   /** DOCUMENT ME! */
-  public static final String FILE_VIEW_CHANGED_PROPERTY = "fileView";
+  public static final String FILE_VIEW_CHANGED_PROPERTY = "fileViewChanged";
 
   /** DOCUMENT ME! */
-  public static final String FILE_HIDING_CHANGED_PROPERTY = 
"fileHidingEnabled";
+  public static final String FILE_HIDING_CHANGED_PROPERTY =
+    "FileHidingChanged";
 
   /** DOCUMENT ME! */
-  public static final String FILE_FILTER_CHANGED_PROPERTY = "fileFilter";
+  public static final String FILE_FILTER_CHANGED_PROPERTY =
+    "fileFilterChanged";
 
   /** DOCUMENT ME! */
-  public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY = 
"fileSelectionMode";
+  public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY =
+    "fileSelectionChanged";
 
   /** DOCUMENT ME! */
-  public static final String ACCESSORY_CHANGED_PROPERTY = "accessory";
+  public static final String ACCESSORY_CHANGED_PROPERTY =
+    "AccessoryChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY = 
"acceptAllFileFilter";
+  public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY =
+    "acceptAllFileFilterUsedChanged";
 
   /** DOCUMENT ME! */
-  public static final String DIALOG_TITLE_CHANGED_PROPERTY = "dialogTitle";
+  public static final String DIALOG_TITLE_CHANGED_PROPERTY =
+    "DialogTitleChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String DIALOG_TYPE_CHANGED_PROPERTY = "dialogType";
+  public static final String DIALOG_TYPE_CHANGED_PROPERTY =
+    "DialogTypeChangedProperty";
 
   /** DOCUMENT ME! */
-  public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY = 
"choosableFileFilter";
+  public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY =
+    "ChoosableFileFilterChangedProperty";
 
   /** DOCUMENT ME! */
   protected AccessibleContext accessibleContext;
@@ -222,6 +237,20 @@
   public JFileChooser(String currentDirectoryPath)
   {
     setup(null);
+    setCurrentDirectory(fsv.createFileObject(currentDirectoryPath));
+  }
+
+  /**
+   * Creates a new JFileChooser object with the specified directory and
+   * FileSystemView.
+   *
+   * @param currentDirectoryPath the directory that should initially be
+   *     shown the filechooser
+   * @param fsv the FileSystemView object to use
+   */
+  public JFileChooser(String currentDirectoryPath, FileSystemView fsv)
+  {
+    setup(fsv);
     setCurrentDirectory(fsv.createFileObject(currentDirectoryPath));
   }
 
Index: kaffe/libraries/javalib/javax/swing/JInternalFrame.java
diff -u kaffe/libraries/javalib/javax/swing/JInternalFrame.java:1.8 
kaffe/libraries/javalib/javax/swing/JInternalFrame.java:1.9
--- kaffe/libraries/javalib/javax/swing/JInternalFrame.java:1.8 Wed Jan 26 
13:40:05 2005
+++ kaffe/libraries/javalib/javax/swing/JInternalFrame.java     Thu May 26 
11:10:40 2005
@@ -862,7 +862,10 @@
   {
     JDesktopPane pane = getDesktopPane();
     if (pane != null)
-      return pane.getLayer(this);
+      // The cast here forces the call to the instance method getLayer()
+      // instead of the static method (this would lead to infinite
+      // recursion).
+      return pane.getLayer((Component) this);
     return -1;
   }
 
Index: kaffe/libraries/javalib/javax/swing/JLayeredPane.java
diff -u kaffe/libraries/javalib/javax/swing/JLayeredPane.java:1.6 
kaffe/libraries/javalib/javax/swing/JLayeredPane.java:1.7
--- kaffe/libraries/javalib/javax/swing/JLayeredPane.java:1.6   Thu Jan 27 
14:02:39 2005
+++ kaffe/libraries/javalib/javax/swing/JLayeredPane.java       Thu May 26 
11:10:40 2005
@@ -130,6 +130,48 @@
   }
 
   /**
+   * Looks up the layer of <code>comp</code> in the component's nearest
+   * JLayeredPane ancestor. If <code>comp</code> is not contained
+   * in a JLayeredPane, the value 0 (default layer) is returned.
+   *
+   * @param comp the component for which the layer is looked up
+   *
+   * @return the layer of <code>comp</code> in its nearest JLayeredPane
+   *     ancestor
+   */
+  public static int getLayer(JComponent comp)
+  {
+    JLayeredPane lp = (JLayeredPane) SwingUtilities.getAncestorOfClass
+      (JLayeredPane.class, comp);
+    if (lp == null)
+      return 0;
+    else
+      // The cast here forces the call to the instance method getLayer()
+      // instead of the static method (this would lead to infinite
+      // recursion).
+      return lp.getLayer((Component) comp);
+  }
+
+  /**
+   * Returns the first JLayeredPane that contains the Component
+   * <code>comp</code> or <code>null</code> if <code>comp</code> is
+   * not contained in a JLayeredPane.
+   *
+   * @param comp the component for which we are searching the JLayeredPane
+   *     ancestor
+   *
+   * @return the first JLayeredPane that contains the Component
+   *     <code>comp</code> or <code>null</code> if <code>comp</code> is
+   *     not contained in a JLayeredPane
+   */
+  public static JLayeredPane getLayeredPaneAbove(Component comp)
+  {
+    JLayeredPane lp = (JLayeredPane) SwingUtilities.getAncestorOfClass
+      (JLayeredPane.class, comp);
+    return lp;
+  }
+
+  /**
    * <p>Returns a pair of ints representing a half-open interval 
    * <code>[top, bottom)</code>, which is the range of component indices 
    * the provided layer number corresponds to.</p>
Index: kaffe/libraries/javalib/javax/swing/JMenuItem.java
diff -u kaffe/libraries/javalib/javax/swing/JMenuItem.java:1.8 
kaffe/libraries/javalib/javax/swing/JMenuItem.java:1.9
--- kaffe/libraries/javalib/javax/swing/JMenuItem.java:1.8      Sat Jan 29 
15:39:57 2005
+++ kaffe/libraries/javalib/javax/swing/JMenuItem.java  Thu May 26 11:10:40 2005
@@ -163,6 +163,7 @@
   protected void init(String text, Icon icon)
   {
     super.init(text, icon);
+    setModel(new DefaultButtonModel());
 
     // Initializes properties for this menu item, that are different
     // from Abstract button properties. 
Index: kaffe/libraries/javalib/javax/swing/JTextArea.java
diff -u kaffe/libraries/javalib/javax/swing/JTextArea.java:1.9 
kaffe/libraries/javalib/javax/swing/JTextArea.java:1.10
--- kaffe/libraries/javalib/javax/swing/JTextArea.java:1.9      Sun May 15 
12:06:48 2005
+++ kaffe/libraries/javalib/javax/swing/JTextArea.java  Thu May 26 11:10:40 2005
@@ -38,7 +38,9 @@
 
 package javax.swing;
 
+import java.awt.Dimension;
 import java.awt.FontMetrics;
+import java.awt.Rectangle;
 
 import javax.swing.text.BadLocationException;
 import javax.swing.text.Document;
@@ -227,6 +229,55 @@
   public boolean getScrollableTracksViewportWidth()
   {
     return lineWrap ? true : super.getScrollableTracksViewportWidth();
+  }
+
+  /**
+   * Returns the increment that is needed to expose exactly one new line
+   * of text. This is implemented here to return the values of
+   * [EMAIL PROTECTED] #getRowHeight} and [EMAIL PROTECTED] getColumnWidth}, 
depending on
+   * the value of the argument <code>direction</code>.
+   *
+   * @param visibleRect the view area that is visible in the viewport
+   * @param orientation either [EMAIL PROTECTED] SwingConstants.VERTICAL} or
+   *     [EMAIL PROTECTED] SwingConstants.HORIZONTAL}
+   * @param direction less than zero for up/left scrolling, greater
+   *     than zero for down/right scrolling
+   *
+   * @return the increment that is needed to expose exactly one new row
+   *     or column of text
+   *
+   * @throws IllegalArgumentException if <code>orientation</code> is invalid
+   */
+  public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation,
+                                        int direction)
+  {
+    if (orientation == SwingConstants.VERTICAL)
+      return getRowHeight();
+    else if (orientation == SwingConstants.HORIZONTAL)
+      return getColumnWidth();
+    else
+      throw new IllegalArgumentException("orientation must be either "
+                                     + "javax.swing.SwingConstants.VERTICAL "
+                                     + "or "
+                                     + "javax.swing.SwingConstants.HORIZONTAL"
+                                     );
+  }
+
+  /**
+   * Returns the preferred size of that text component in the case
+   * it is embedded within a JScrollPane. This uses the column and
+   * row settings if they are explicitly set, or fall back to
+   * the superclass's behaviour.
+   *
+   * @return the preferred size of that text component in the case
+   *     it is embedded within a JScrollPane
+   */
+  public Dimension getPreferredScrollableViewportSize()
+  {
+    if ((rows > 0) && (columns > 0))
+      return new Dimension(columns * getColumnWidth(), rows * getRowHeight());
+    else
+      return super.getPreferredScrollableViewportSize();
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/JViewport.java
diff -u kaffe/libraries/javalib/javax/swing/JViewport.java:1.8 
kaffe/libraries/javalib/javax/swing/JViewport.java:1.9
--- kaffe/libraries/javalib/javax/swing/JViewport.java:1.8      Mon Feb 14 
21:20:19 2005
+++ kaffe/libraries/javalib/javax/swing/JViewport.java  Thu May 26 11:10:44 2005
@@ -42,8 +42,12 @@
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Insets;
+import java.awt.LayoutManager;
 import java.awt.Point;
 import java.awt.Rectangle;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.io.Serializable;
 
 import javax.swing.border.Border;
 import javax.swing.event.ChangeEvent;
@@ -93,6 +97,59 @@
  */
 public class JViewport extends JComponent
 {
+
+  /**
+   * A [EMAIL PROTECTED] java.awt.event.ComponentListener} that listens for
+   * changes of the view's size. This class forbids changes of the view
+   * component's size that would exceed the viewport's size.
+   */
+  protected class ViewListener
+    extends ComponentAdapter
+    implements Serializable
+  {
+    /**
+     * Creates a new instance of ViewListener.
+     */
+    protected ViewListener()
+    {
+    }
+
+    /**
+     * Receives notification when a component (in this case: the view
+     * component) changes it's size.
+     *
+     * @param ev the ComponentEvent describing the change
+     */
+    public void componentResized(ComponentEvent ev)
+    {
+      // According to some tests that I did with Sun's implementation
+      // this class is supposed to make sure that the view component
+      // is not resized to a larger size than the viewport.
+      // This is not documented anywhere. What I did is: I subclassed JViewport
+      // and ViewListener and 'disabled' the componentResized method by
+      // overriding it and not calling super.componentResized().
+      // When this method is disabled I can set the size on the view component
+      // normally, when it is enabled, it gets immediatly resized back,
+      // after a resize attempt that would exceed the Viewport's size.
+      Component comp = ev.getComponent();
+      Dimension newSize = comp.getSize();
+      Dimension viewportSize = getSize();
+      boolean revert = false;
+      if (newSize.width > viewportSize.width)
+        {
+          newSize.width = viewportSize.width;
+          revert = true;
+        }
+      if (newSize.height > viewportSize.height)
+        {
+          newSize.height = viewportSize.height;
+          revert = true;
+        }
+      if (revert == true)
+        comp.setSize(newSize);
+    }
+  }
+
   private static final long serialVersionUID = -6925142919680527970L;
   
   public static final int SIMPLE_SCROLL_MODE = 0;
@@ -125,10 +182,16 @@
 
   Point lastPaintPosition;
 
+  /**
+   * The ViewListener instance.
+   */
+  ViewListener viewListener;
+
   public JViewport()
   {
     setOpaque(true);
     setScrollMode(BLIT_SCROLL_MODE);
+    setLayout(createLayoutManager());
     updateUI();
   }
 
@@ -267,9 +330,17 @@
   public void setView(Component v)
   {
     while (getComponentCount() > 0)
-      remove(0);
+      {
+        if (viewListener != null)
+          getView().removeComponentListener(viewListener);
+        remove(0);
+      }
+
     if (v != null)
       {
+        if (viewListener == null)
+          viewListener = createViewListener();
+        v.addComponentListener(viewListener);
         add(v);
         fireStateChanged();
       }
@@ -391,5 +462,27 @@
   {
     if (border != null)
       throw new IllegalArgumentException();
+  }
+
+  /**
+   * Creates a [EMAIL PROTECTED] ViewListener} that is supposed to listen for
+   * size changes on the view component.
+   *
+   * @return a ViewListener instance
+   */
+  protected ViewListener createViewListener()
+  {
+    return new ViewListener();
+  }
+
+  /**
+   * Creates the LayoutManager that is used for this viewport. Override
+   * this method if you want to use a custom LayoutManager.
+   *
+   * @return a LayoutManager to use for this viewport
+   */
+  protected LayoutManager createLayoutManager()
+  {
+    return new ViewportLayout();
   }
 }
Index: kaffe/libraries/javalib/javax/swing/SwingUtilities.java
diff -u kaffe/libraries/javalib/javax/swing/SwingUtilities.java:1.13 
kaffe/libraries/javalib/javax/swing/SwingUtilities.java:1.14
--- kaffe/libraries/javalib/javax/swing/SwingUtilities.java:1.13        Sat May 
21 15:13:39 2005
+++ kaffe/libraries/javalib/javax/swing/SwingUtilities.java     Thu May 26 
11:10:44 2005
@@ -352,6 +352,25 @@
   }
 
   /**
+   * Returns the first ancestor of <code>comp</code> that is a [EMAIL 
PROTECTED] Window}
+   * or <code>null</code> if <code>comp</code> is not contained in a
+   * [EMAIL PROTECTED] Window}.
+   *
+   * This is equivalent to calling
+   * <code>getAncestorOfClass(Window, comp)</code> or
+   * <code>windowForComponent(comp)</code>.
+   *
+   * @param comp the component for which we are searching the ancestor Window
+   *
+   * @return the first ancestor Window of <code>comp</code> or
+   *     <code>null</code> if <code>comp</code> is not contained in a Window
+   */
+  public Window getWindowAncestor(Component comp)
+  {
+    return (Window) getAncestorOfClass(Window.class, comp);
+  }
+
+  /**
    * Equivalent to calling <code>getAncestorOfClass(Window, comp)</code>.
    *
    * @param comp The component to search for an ancestor window 
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java
diff -u 
kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.12 
kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.13
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java:1.12   
Sat May 21 15:13:43 2005
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicLookAndFeel.java        
Thu May 26 11:10:44 2005
@@ -911,7 +911,7 @@
           },
       "TextPane.margin", new InsetsUIResource(3, 3, 3, 3),
       "TextPane.selectionBackground", new ColorUIResource(Color.black),
-      "TextPane.selectionForeground", new ColorUIResource(Color.white)/*,
+      "TextPane.selectionForeground", new ColorUIResource(Color.white),
       "TitledBorder.border", new BorderUIResource.EtchedBorderUIResource(),
       "TitledBorder.font", new FontUIResource("Dialog", Font.PLAIN, 12),
       "TitledBorder.titleColor", new ColorUIResource(darkShadow),
@@ -1028,7 +1028,7 @@
       "Tree.textForeground", new ColorUIResource(Color.black),
       "Viewport.background", new ColorUIResource(light),
       "Viewport.foreground", new ColorUIResource(Color.black),
-      "Viewport.font", new FontUIResource("Dialog", Font.PLAIN, 12)*/
+      "Viewport.font", new FontUIResource("Dialog", Font.PLAIN, 12)
     };
     defaults.putDefaults(uiDefaults);
   }
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicSplitPaneUI.java
diff -u 
kaffe/libraries/javalib/javax/swing/plaf/basic/BasicSplitPaneUI.java:1.4 
kaffe/libraries/javalib/javax/swing/plaf/basic/BasicSplitPaneUI.java:1.5
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicSplitPaneUI.java:1.4    
Sun Oct 24 10:44:37 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicSplitPaneUI.java        
Thu May 26 11:10:44 2005
@@ -1348,7 +1348,11 @@
    */
   public void paint(Graphics g, JComponent jc)
   {
-    // Do nothing. All the painting is handled by children.
+    // Make sure that the location is valid
+    int divLoc = splitPane.getDividerLocation();
+    int valLoc = validLocation(divLoc);
+    if (divLoc != valLoc)
+      splitPane.setDividerLocation(valLoc);
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.11 
kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.12
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java:1.11        
Sun May 15 18:03:46 2005
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicTextUI.java     Thu May 
26 11:10:44 2005
@@ -466,7 +466,20 @@
 
     return new Dimension((int) w, (int) h);
   }
-  
+
+  /**
+   * Returns the maximum size for text components that use this UI.
+   *
+   * This returns (Integer.MAX_VALUE, Integer.MAX_VALUE).
+   *
+   * @return the maximum size for text components that use this UI
+   */
+  public Dimension getMaximumSize(JComponent c)
+  {
+    // Sun's implementation returns Integer.MAX_VALUE here, so do we.
+    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+  }
+
   public final void paint(Graphics g, JComponent c)
   {
     paintSafely(g);
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java:1.5 
kaffe/libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java:1.6
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java:1.5     
Sun Nov 14 20:03:26 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicViewportUI.java Thu May 
26 11:10:44 2005
@@ -103,7 +103,6 @@
   public void installUI(JComponent c) 
   {
     super.installUI(c);
-    c.setLayout(new ViewportLayout());
     installListeners(c);
   }
 
Index: kaffe/libraries/javalib/javax/swing/text/JTextComponent.java
diff -u kaffe/libraries/javalib/javax/swing/text/JTextComponent.java:1.17 
kaffe/libraries/javalib/javax/swing/text/JTextComponent.java:1.18
--- kaffe/libraries/javalib/javax/swing/text/JTextComponent.java:1.17   Sat May 
21 15:13:45 2005
+++ kaffe/libraries/javalib/javax/swing/text/JTextComponent.java        Thu May 
26 11:10:45 2005
@@ -69,6 +69,7 @@
 import javax.swing.JViewport;
 import javax.swing.KeyStroke;
 import javax.swing.Scrollable;
+import javax.swing.SwingConstants;
 import javax.swing.Timer;
 import javax.swing.TransferHandler;
 import javax.swing.UIManager;
@@ -1130,19 +1131,39 @@
 
   public Dimension getPreferredScrollableViewportSize()
   {
-    return null;
+    return getPreferredSize();
   }
 
   public int getScrollableUnitIncrement(Rectangle visible, int orientation,
                                         int direction)
   {
-    return 0;
+    // We return 1/10 of the visible area as documented in Sun's API docs.
+    if (orientation == SwingConstants.HORIZONTAL)
+      return visible.width / 10;
+    else if (orientation == SwingConstants.VERTICAL)
+      return visible.height / 10;
+    else
+      throw new IllegalArgumentException("orientation must be either "
+                                      + "javax.swing.SwingConstants.VERTICAL "
+                                      + "or "
+                                      + "javax.swing.SwingConstants.HORIZONTAL"
+                                         );
   }
 
   public int getScrollableBlockIncrement(Rectangle visible, int orientation,
                                          int direction)
   {
-    return 0;
+    // We return the whole visible area as documented in Sun's API docs.
+    if (orientation == SwingConstants.HORIZONTAL)
+      return visible.width;
+    else if (orientation == SwingConstants.VERTICAL)
+      return visible.height;
+    else
+      throw new IllegalArgumentException("orientation must be either "
+                                      + "javax.swing.SwingConstants.VERTICAL "
+                                      + "or "
+                                      + "javax.swing.SwingConstants.HORIZONTAL"
+                                         );
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/tree/TreePath.java
diff -u kaffe/libraries/javalib/javax/swing/tree/TreePath.java:1.1 
kaffe/libraries/javalib/javax/swing/tree/TreePath.java:1.2
--- kaffe/libraries/javalib/javax/swing/tree/TreePath.java:1.1  Thu Jul 22 
19:37:43 2004
+++ kaffe/libraries/javalib/javax/swing/tree/TreePath.java      Thu May 26 
11:10:45 2005
@@ -51,250 +51,247 @@
 {
   static final long serialVersionUID = 4380036194768077479L;
 
-       //-------------------------------------------------------------
-       // Variables --------------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * path
-        */
-       private Object[]        path    = null;
-
-
-       //-------------------------------------------------------------
-       // Initialization ---------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * Constructor TreePath
-        * @param path TODO
-        */
-       public TreePath(Object[] path) {
-
-               // Create Path
-               this.path = new Object[path.length];
-               System.arraycopy(path, 0, this.path, 0, path.length);
-
-       } // TreePath()
-
-       /**
-        * Constructor TreePath
-        * @param element TODO
-        */
-       public TreePath(Object element) {
-
-               // Create Path
-               path = new Object[1];
-               path[0] = element;
-
-       } // TreePath()
-
-       /**
-        * Constructor TreePath
-        * @param path TODO
-        * @param element TODO
-        */
-       protected TreePath(TreePath path, Object element) {
-
-               // Variables
-               Object[]        treepath;
-
-               // Get Tree Path
-               treepath = path.getPath();
-
-               // Create Tree Path
-               this.path = new Object[treepath.length + 1];
-               System.arraycopy(treepath, 0, this.path, 0, treepath.length);
-               this.path[treepath.length] = element;
-
-       } // TreePath()
-
-       /**
-        * Constructor TreePath
-        * @param path TODO
-        * @param length TODO
-        */
-       protected TreePath(Object[] path, int length) {
-
-               // Create Path
-               this.path = new Object[length];
-               System.arraycopy(path, 0, this.path, 0, length);
-
-       } // TreePath()
-
-       /**
-        * Constructor TreePath
-        */
-       protected TreePath() {
-               path = new Object[0];
-       } // TreePath()
-
-
-       //-------------------------------------------------------------
-       // Methods ----------------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * hashCode
-        * @returns int
-        */
-       public int hashCode() {
-               return getLastPathComponent().hashCode();
-       } // hashCode()
-
-       /**
-        * equals
-        * @param object TODO
-        * @returns boolean
-        */
-       public boolean equals(Object object) {
-
-               // Variables
-               Object[]        treepath;
-               int                     index;
-
-               // Check for TreePath
-               if (object instanceof TreePath) {
-
-                       // Get Path Elements
-                       treepath = ((TreePath) object).getPath();
-
-                       // Check length
-                       if (treepath.length != path.length) {
-                               return false;
-                       } // if
-
-                       // Check Elements
-                       for (index = 0; index < path.length; index++) {
-                               if (treepath[index] != path[index]) {
-                                       return false;
-                               } // if
-                       } // for
-
-                       // Tree Path's are equals
-                       return true;
-
-               } // if
-
-               // Unequal
-               return false;
-
-       } // equals()
-
-       /**
-        * toString
-        * @returns String
-        */
-       public String toString() {
-               return null; // TODO
-       } // toString()
-
-       /**
-        * writeObject
-        * @param value0 TODO
-        * @exception IOException TODO
-        */
-       private void writeObject(ObjectOutputStream value0) throws IOException {
-               // TODO
-       } // writeObject()
-
-       /**
-        * readObject
-        * @param value0 TODO
-        * @exception IOException TODO
-        * @exception ClassNotFoundException TODO
-        */
-       private void readObject(ObjectInputStream value0) throws IOException, 
ClassNotFoundException {
-               // TODO
-       } // readObject()
-
-       /**
-        * getPath
-        * @returns Object[]
-        */
-       public Object[] getPath() {
-               return path;
-       } // getPath()
-
-       /**
-        * getLastPathComponent
-        * @returns Object
-        */
-       public Object getLastPathComponent() {
-               return path[path.length - 1];
-       } // getLastPathComponent()
-
-       /**
-        * getPathCount
-        * @returns int
-        */
-       public int getPathCount() {
-               return path.length;
-       } // getPathCount()

*** Patch too long, truncated ***

_______________________________________________
kaffe mailing list
kaffe@kaffe.org
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to