harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r496284 - /harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java
Date Mon, 15 Jan 2007 11:45:49 GMT
Author: varlax
Date: Mon Jan 15 03:45:48 2007
New Revision: 496284

URL: http://svn.apache.org/viewvc?view=rev&rev=496284
Log:
Applied HARMONY-2810 [classlib][awt] JUnit AWT-based TestRunner can't be started
Tested on J9/SUSE9@ia32

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java?view=diff&rev=496284&r1=496283&r2=496284
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java Mon
Jan 15 03:45:48 2007
@@ -48,6 +48,8 @@
     private static final long serialVersionUID = -3304312411574666869L;
 
     private final static int BORDER_SIZE = 2;
+    
+    private final static Font DEFAULT_FONT = new Font("dialog", Font.PLAIN, 12); //$NON-NLS-1$
 
     private final AWTListenerList<ActionListener> actionListeners = new AWTListenerList<ActionListener>(
             this);
@@ -1409,8 +1411,13 @@
     }
 
     private Dimension getMaxCharSize(Graphics g) {
-        FontRenderContext frc = ((Graphics2D) g).getFontRenderContext();
-        return getFont().getStringBounds("W", frc).getBounds().getSize(); //$NON-NLS-1$
+        final FontRenderContext frc = ((Graphics2D) g).getFontRenderContext();
+        return getListFont().getStringBounds("W", frc).getBounds().getSize(); //$NON-NLS-1$
+    }
+    
+    private Font getListFont() {
+        final Font f = getFont();
+        return f == null ? DEFAULT_FONT : f;
     }
 
     private void doRepaint(Rectangle r) {
@@ -1446,7 +1453,7 @@
 
     @SuppressWarnings("deprecation")
     private Dimension getItemSize() {
-        FontMetrics fm = toolkit.getFontMetrics(getFont());
+        FontMetrics fm = toolkit.getFontMetrics(getListFont());
         int itemHeight = fm.getHeight() + 2;
         return new Dimension(prefWidth - 2 * BORDER_SIZE, itemHeight);
     }



Mime
View raw message