[kaffe] CVS kaffe (robilad): Resynced with GNU Clasaspath: various AWT fixes

Kaffe CVS cvs-commits at kaffe.org
Mon Feb 14 13:35:27 PST 2005


PatchSet 5543 
Date: 2005/02/14 21:20:17
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Clasaspath: various AWT fixes

2005-02-14  Dalibor Topic  <robilad at kaffe.org>

Resynced with GNU Classpath.

2005-02-13  Mark Wielaard  <mark at klomp.org>

* java/awt/AWTKeyStroke.java (getAWTKeyStroke(String)): Throw
IllegalArgumentException when the given String is null.

* javax/swing/KeyStroke.java (getKeyStroke(String)): Return null
when given keystoke sequence cannot be parsed.

* javax/swing/JRootPane.java (setJMenuBar): Remove current menubar
if one is installed. Only install the given menubar is not null.

* javax/swing/JViewport.java (getViewSize): Return an empty
Dimension when the view isn't set or preferred component size when
no viewSize is set.

* javax/swing/ViewportLayout.java (preferredLayoutSize): Return an
empty Dimension when there is no view set.
(minimumLayoutSize): Likewise.
(layoutContainer): Don't try to layout when there is no view.

Members: 
	libraries/javalib/java/awt/AWTKeyStroke.java:1.4->1.5 
	libraries/javalib/javax/swing/JRootPane.java:1.8->1.9 
	libraries/javalib/javax/swing/JViewport.java:1.7->1.8 
	libraries/javalib/javax/swing/KeyStroke.java:1.6->1.7 
	libraries/javalib/javax/swing/ViewportLayout.java:1.4->1.5 
	ChangeLog:1.3587->1.3588 

Index: kaffe/libraries/javalib/java/awt/AWTKeyStroke.java
diff -u kaffe/libraries/javalib/java/awt/AWTKeyStroke.java:1.4 kaffe/libraries/javalib/java/awt/AWTKeyStroke.java:1.5
--- kaffe/libraries/javalib/java/awt/AWTKeyStroke.java:1.4	Mon Oct  4 09:01:29 2004
+++ kaffe/libraries/javalib/java/awt/AWTKeyStroke.java	Mon Feb 14 21:20:17 2005
@@ -1,5 +1,5 @@
 /* AWTKeyStroke.java -- an immutable key stroke
-   Copyright (C) 2002, 2004  Free Software Foundation
+   Copyright (C) 2002, 2004, 2005  Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -404,15 +404,16 @@
    * </code>      
    *
    * @param s the string to parse
+   * @throws IllegalArgumentException if s is null or cannot be parsed
    * @return the specified keystroke
-   * @throws NullPointerException if s is null
-   * @throws IllegalArgumentException if s cannot be parsed
    */
   public static AWTKeyStroke getAWTKeyStroke(String s)
   {
+    if (s == null)
+      throw new IllegalArgumentException("null argument");
     StringTokenizer t = new StringTokenizer(s, " ");
     if (! t.hasMoreTokens())
-      throw new IllegalArgumentException();
+      throw new IllegalArgumentException("no tokens '" + s + "'");
     int modifiers = 0;
     boolean released = false;
     String token = null;
@@ -443,7 +444,8 @@
                                          KeyEvent.VK_UNDEFINED, modifiers,
                                          false);
               }
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException("Invalid 'typed' argument '"
+			    		       + s + "'");
           }
         else if ("pressed".equals(token))
           {
@@ -464,8 +466,11 @@
     while (t.hasMoreTokens());
     // Now token contains the VK name we must parse.
     Integer code = (Integer) vktable.get(token);
-    if (code == null || t.hasMoreTokens())
-      throw new IllegalArgumentException();
+    if (code == null)
+      throw new IllegalArgumentException("Unknown token '" + token
+					 + "' in '" + s + "'");
+    if (t.hasMoreTokens())
+      throw new IllegalArgumentException("Too many tokens: " + s);
     return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(),
                            modifiers, released);
   }
Index: kaffe/libraries/javalib/javax/swing/JRootPane.java
diff -u kaffe/libraries/javalib/javax/swing/JRootPane.java:1.8 kaffe/libraries/javalib/javax/swing/JRootPane.java:1.9
--- kaffe/libraries/javalib/javax/swing/JRootPane.java:1.8	Thu Jan  6 17:31:26 2005
+++ kaffe/libraries/javalib/javax/swing/JRootPane.java	Mon Feb 14 21:20:19 2005
@@ -346,8 +346,12 @@
    */
   public void setJMenuBar(JMenuBar m)
   {
+    JLayeredPane jlPane = getLayeredPane();
+    if (menuBar != null)
+      jlPane.remove(menuBar);
     menuBar = m;
-    getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
+    if (menuBar != null)
+      jlPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
   }
 
   /**
Index: kaffe/libraries/javalib/javax/swing/JViewport.java
diff -u kaffe/libraries/javalib/javax/swing/JViewport.java:1.7 kaffe/libraries/javalib/javax/swing/JViewport.java:1.8
--- kaffe/libraries/javalib/javax/swing/JViewport.java:1.7	Wed Jan 26 13:40:05 2005
+++ kaffe/libraries/javalib/javax/swing/JViewport.java	Mon Feb 14 21:20:19 2005
@@ -158,12 +158,23 @@
     fireStateChanged();
   }
 
+  /**
+   * Returns the viewSize when set, or the preferred size of the set
+   * Component view.  If no viewSize and no Component view is set an
+   * empty Dimension is returned.
+   */
   public Dimension getViewSize()
   {
     if (isViewSizeSet)
       return viewSize;
     else
-      return getView().getSize();
+      {
+	Component view = getView();
+	if (view != null)
+	  return view.getPreferredSize();
+	else
+	  return new Dimension();
+      }
   }
 
 
Index: kaffe/libraries/javalib/javax/swing/KeyStroke.java
diff -u kaffe/libraries/javalib/javax/swing/KeyStroke.java:1.6 kaffe/libraries/javalib/javax/swing/KeyStroke.java:1.7
--- kaffe/libraries/javalib/javax/swing/KeyStroke.java:1.6	Thu Jan 27 14:02:40 2005
+++ kaffe/libraries/javalib/javax/swing/KeyStroke.java	Mon Feb 14 21:20:20 2005
@@ -96,9 +96,22 @@
     return (KeyStroke) getAWTKeyStroke(keyCode, modifiers);
   }
 
+  /**
+   * Returns the KeyStroke according to <code>getAWTKeyStroke()</code>.
+   * But it returns null instead of throwing
+   * <code>IllegalArugmentException</code> when
+   * the keystoke sequence cannot be parsed from the given string.
+   */
   public static KeyStroke getKeyStroke(String str) 
   {
-    return (KeyStroke) getAWTKeyStroke(str);
+    try
+      {
+	return (KeyStroke) getAWTKeyStroke(str);
+      }
+    catch (IllegalArgumentException iae)
+      {
+	return null;
+      }
   }
 
   public static KeyStroke getKeyStrokeForEvent(KeyEvent event) 
Index: kaffe/libraries/javalib/javax/swing/ViewportLayout.java
diff -u kaffe/libraries/javalib/javax/swing/ViewportLayout.java:1.4 kaffe/libraries/javalib/javax/swing/ViewportLayout.java:1.5
--- kaffe/libraries/javalib/javax/swing/ViewportLayout.java:1.4	Wed Jan  5 19:37:12 2005
+++ kaffe/libraries/javalib/javax/swing/ViewportLayout.java	Mon Feb 14 21:20:20 2005
@@ -63,17 +63,25 @@
   public void removeLayoutComponent(Component c) 
   {
   }
+
   public Dimension preferredLayoutSize(Container parent) 
   {
     JViewport vp = (JViewport)parent;
     Component view = vp.getView();
-    return view.getPreferredSize();
+    if (view != null)
+      return view.getPreferredSize();
+    else
+      return new Dimension();
   }
+
   public Dimension minimumLayoutSize(Container parent) 
   {
     JViewport vp = (JViewport)parent;
     Component view = vp.getView();
-    return view.getMinimumSize();
+    if (view != null)
+      return view.getMinimumSize();
+    else
+      return new Dimension();
   }
 
   /**
@@ -112,6 +120,9 @@
 
     JViewport port = (JViewport) parent;    
     Component view = port.getView();
+
+    if (view == null)
+      return;
 
     // These dimensions and positions are in *view space*.  Do not mix
     // variables in here from port space (eg. parent.getBounds()). This
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3587 kaffe/ChangeLog:1.3588
--- kaffe/ChangeLog:1.3587	Mon Feb 14 21:05:36 2005
+++ kaffe/ChangeLog	Mon Feb 14 21:19:57 2005
@@ -4,6 +4,30 @@
 	
 	2005-02-13  Mark Wielaard  <mark at klomp.org>
 
+	* java/awt/AWTKeyStroke.java (getAWTKeyStroke(String)): Throw
+	IllegalArgumentException when the given String is null.
+
+	* javax/swing/KeyStroke.java (getKeyStroke(String)): Return null
+	when given keystoke sequence cannot be parsed.
+
+	* javax/swing/JRootPane.java (setJMenuBar): Remove current menubar
+	if one is installed. Only install the given menubar is not null.
+
+	* javax/swing/JViewport.java (getViewSize): Return an empty
+	Dimension when the view isn't set or preferred component size when
+	no viewSize is set.
+
+	* javax/swing/ViewportLayout.java (preferredLayoutSize): Return an
+	empty Dimension when there is no view set.
+	(minimumLayoutSize): Likewise.
+	(layoutContainer): Don't try to layout when there is no view.
+
+2005-02-14  Dalibor Topic  <robilad at kaffe.org>
+
+	Resynced with GNU Classpath.
+	
+	2005-02-13  Mark Wielaard  <mark at klomp.org>
+
 	# Fixes bug #11957
 	* java/io/ObjectInputStream.java (resolveClass): Don't check "void"
 	twice.



More information about the kaffe mailing list