<AWT Dev> Better support for external Toolkits/GraphicEnvs

Oleg Sukhodolsky Oleg.Sukhodolsky at Sun.COM
Wed Jun 20 06:56:29 PDT 2007

Hi Roman,

comments inlined.

Roman Kennke wrote:
> Hi there,
> At the moment I'm trying to get GNU Classpath's GTK peers (and a handful
> of own peer/graphicsenv implementations for embedded systems) working
> with OpenJDK. I'm encountering a couple of problems and I ask myself if
> the OpenJDK project has any interest in patches to improve support for
> external toolkits.
> For example, there's a bunch of places with code like this:
>     private void initPeer() {
>         if (Toolkit.getDefaultToolkit() instanceof HeadlessToolkit){
>             peer =
> ((HeadlessToolkit)Toolkit.getDefaultToolkit()).createKeyboardFocusManagerPeer(this);
>         }
>         if (Toolkit.getDefaultToolkit() instanceof SunToolkit){        
>             peer =
> ((SunToolkit)Toolkit.getDefaultToolkit()).createKeyboardFocusManagerPeer(this);                  
>         }
>     }
> Obviously, this wouldn't work with anything except the built-in
> toolkits.

it is a sweet dream to have pluggable toolkit.  So, the answer is yes we 
would like to clean such places.  As usual the only problem is a price 
:)  For example, for this particular case you will need to add new 
method to Toolkit, for others you may need to do even more :(

So, although we would be happy to clean the code and make the toolkit 
pluggable, I, personally, afraid that this is very hard.  And thus even 
if you are going to to this I'd suggest to start from places which do 
not require API changes.

> Other areas where I suspect big problems are fonts and probably images.
> It seems like OpenJDK has no support for a pluggable font implementation
> at all. However, the GTK peers rely on their own implementation (which
> is abstracted behind an extension of FontPeer).

well, fonts and images are 2D areas :) you should propose this on their 

> With the new FB-Toolkit project approved, I'd guess that there would be
> interest in developing a clean(er) interface and allowing alternative
> peers and graphics environments to be plugged in, is that correct? If so
> I would prepare some patches soon.

I'd suggest to start FBToolkit as subclass of SunToolkit, because this 
will simplify the process, but, as I said above, patches are welcome 
(although do not expect that all wil be accepted ;)

Regards, Oleg.

More information about the awt-dev mailing list