classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] FYI: JComponent fix


From: Robert Schuster
Subject: Re: [cp-patches] FYI: JComponent fix
Date: Thu, 30 Jun 2005 00:30:39 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.8) Gecko/20050514

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.
I have a question/suggestion to this piece of code:

>    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();
> +      }
>    }
>  
You said the reason for creating the new Graphics2D object is to
preserve the state of g. However I find the solution inappropriate. The
"right way" of doing this would IMHO be using getTransform() (and
setTransform() afterwards).

Btw: In the future all Graphics instances will silently be Graphics2D
instances (just as they are in the reference implementation since >=
1.2). A comment that explains this for future changes would be nice.

cu
Robert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFCwyEPG9cfwmwwEtoRAgnLAJ9fvRdZruoGOZaDEyIEmEboLU7fmgCggW0C
tTxR9cci9n0XXASBLWIVzxU=
=GDId
-----END PGP SIGNATURE-----




reply via email to

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