classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: JComponent fix


From: Roman Kennke
Subject: [cp-patches] FYI: JComponent fix
Date: Wed, 29 Jun 2005 16:41:42 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

The painting in JComponent was slighly wrong. See ChangeLog entries and diff for details.

2005-06-29  Roman Kennke  <address@hidden>

       * javax/swing/JComponent.java
       (getComponentGraphics): Do not replicate the Graphics at this
       point. This is moved into paintComponent.
       (paintComponent): Replicate the Graphics object before going into
       the tree. This makes sure that the state is preserved and is
       what is specified in the JDKs API docs.

/Roman

Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.48
diff -u -r1.48 JComponent.java
--- javax/swing/JComponent.java 27 Jun 2005 22:35:55 -0000      1.48
+++ javax/swing/JComponent.java 29 Jun 2005 14:38:11 -0000
@@ -872,19 +872,9 @@
    */
   protected Graphics getComponentGraphics(Graphics g)
   {    
-    if (g instanceof Graphics2D)
-      {
-       g.setFont (this.getFont());
-       g.setColor (this.getForeground());
-       return g;
-      }
-    else
-      {
-        Graphics g2 = g.create ();
-        g2.setFont (this.getFont());
-        g2.setColor (this.getForeground());
-        return g2;
-      }
+    g.setFont (this.getFont());
+    g.setColor (this.getForeground());
+    return g;
   }
 
   /**
@@ -1510,7 +1500,14 @@
   protected void paintComponent(Graphics g)
   {
     if (ui != null)
-      ui.update(g, this);
+      {
+        Graphics g2 = g;
+        if (!(g instanceof Graphics2D))
+          g2 = g.create();
+        ui.update(getComponentGraphics(g2), this);
+        if (!(g instanceof Graphics2D))
+          g2.dispose();
+      }
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]