classpath
[Top][All Lists]
Advanced

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

Re: extended peers


From: Sascha Brawer
Subject: Re: extended peers
Date: Fri, 12 Sep 2003 15:29:21 +0200

Brian Jones <address@hidden> wrote on Fri, 12 Sep 2003 08:58:29 -0400:

>Sascha Brawer <address@hidden> writes:
>
>> package java.awt;
>> 
>> import java.awt.Toolkit;
>> import gnu.java.awt.ClasspathToolkit;
>> 
>> public abstract class GraphicsEnvironment
>> {
>>   private static GraphicsEnvironment localGraphicsEnvironment;
>> 
>>   public static synchronized getLocalGraphicsEnvironment()
>>   {
>>     if (localGraphicsEnvironment == null)
>>     {
>>       ClasspathToolkit ctk;
>> 
>>       ctk = (ClasspathToolkit) Toolkit.getDefaultToolkit();
>>       localGraphicsEnvironment = ctk.getLocalGraphicsEnvironment();
>>     }
>> 
>>     return localGraphicsEnvironment;
>>   }
>> }
>
>I think you can store the reference as a Toolkit only.  What parts of
>our code would rely upon having a ClasspathToolkit with the additional
>Font related stuff?

You mean "storing" in the local variable ctk? One also could write

  localGraphicsEnvironment =
    ((ClasspathToolkit) Toolkit.getDefaultToolkit())
    .getLocalGraphicsEnvironment();

but this seems a bit less legible. The cast is needed because the method
to create a concrete GraphicsEnvironment is introduced by
ClasspathToolkit, not by Toolkit.

-- Sascha

Sascha Brawer, address@hidden, http://www.dandelis.ch/people/brawer/ 






reply via email to

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