[Blindmath] Using Java Draw2D in an SWT GUI

Carolyn MacLeod Carolyn_MacLeod at ca.ibm.com
Thu Feb 23 05:04:38 UTC 2012


Hi again.

Sorry to take so long to reply.

JFrame is not an embeddable component, so SWT (or any other embeddor) 
can't embed JFrames.
SWT_AWT.new_Frame() returns a subclass of EmbeddedFrame, which is a 
sibling of JFrame but it does not have a root pane.
JApplet is embeddable and it has a root pane. Can you make do with a 
JApplet instead of a JFrame?

I wrote another snippet for you (attached) that takes the root pane out of 
a JFrame and sets it into a JApplet in an SWT GUI.
Hopefully you could do something similar with a JFrame from your 
textbook's sample code.
But this won't solve the whole problem, because the Swing controls from 
the JFrame still won't be accessible unless you have the JAB installed and 
use an AT that works with it.
(Question for you: Are Swing controls really that inaccessible? Is the JAB 
hard to install? Don't AT usually work once the JAB is installed? I don't 
know because I don't use Swing.)

Regarding event integration, this article might be helpful:
http://www.eclipse.org/articles/Article-Swing-SWT-Integration/index.html
The rule of thumb is to use SwingUtilities.invokeLater() and 
Display.asyncExec() to pass work from AWT/Swing to SWT and vice-versa.
This article also discusses the tab traversal "glitch" that I tripped over 
in the snippet I sent you earlier, and they show how to fix it in their 
example code.

> I really do believe in the OOP concept of "reuse, don't reinvent,"
So do we, which is why we reused the OS controls instead of drawing our 
own.  :)
We did talk about this with Sun in the beginning, but unfortunately it 
didn't work out.

Also, I happened to trip over these other two snippets that manipulate 
BufferedImage and JAI TiledImage from within SWT.
I am including them here in case they are helpful:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=119363#c13
https://bugs.eclipse.org/bugs/show_bug.cgi?id=119363#c14

Hope this helps,
Carolyn







From:
Richard Baldwin <baldwin at dickbaldwin.com>
To:
Blind Math list for those interested in mathematics <blindmath at nfbnet.org>
Date:
01/31/2012 01:30 PM
Subject:
Re: [Blindmath] Using Java Draw2D in an SWT GUI
Sent by:
blindmath-bounces at nfbnet.org



Thanks for responding to my concerns. I will definitely take a look at 
your
workabound and see how much it helps. Hopefully, I will be pleased with 
the
results.

I suspect, however, that simply providing compatibility at the AWT Canvas
level won't help much with my main concern. I already knew of one way to 
do
that. I also already knew how to embed AWT Frame objects in an SWT object.
Unfortunately, I don't know how to easily integrate events fired by those
AWT components into the SWT event handling system and I don't know how to
embed Swing JFrame objects and/or their events in SWT objects.

I know how to write new code that will play reasonably well with SWT. That
isn't my main concern. I really do believe in the OOP concept of "reuse,
don't reinvent," and my main concern is the lack of compatibility of SWT
with existing unmodified graphics libraries, which typically produce
graphic outputs in Swing JFrame objects. Until we can successfully embed
JFrame objects in SWT objects, and until we can easily integrate the event
handling mechanisms of the two systems, the use of those libraries without
modification of the libraries will probably be very difficult at best and
off limits at worst.

Hopefully someone will prove me wrong on this.

Dick Baldwin

On Tue, Jan 31, 2012 at 11:03 AM, Carolyn MacLeod <
Carolyn_MacLeod at ca.ibm.com> wrote:

> Thank-you, Michael!
> Carolyn
>
>
>
> From:
> "Michael Whapples" <mwhapples at aim.com>
> To:
> "Blind Math list for those interested in mathematics"
> <blindmath at nfbnet.org>
> Date:
> 31/01/2012 11:30 AM
> Subject:
> Re: [Blindmath] Using Java Draw2D in an SWT GUI
> Sent by:
> blindmath-bounces at nfbnet.org
>
>
>
> Hello,
> Thanks for taking the time to do this. I know you have asked questions 
on
> the orca-list about improving accessibility in SWT and eclipse and its
> certainly appreciated. In my oppinion SWT is one of the few, if not the
> best, GUI toolkits for making accessible applications which are also
> cross-platform.
>
> Regards
>
> Michael whapples
>
> -----Original Message-----
> From: Carolyn MacLeod
> Sent: Tuesday, January 31, 2012 4:09 PM
> To: blindmath at nfbnet.org
> Subject: [Blindmath] Using Java Draw2D in an SWT GUI
>
> Hello, list.
>
> My name is Carolyn and I am on the Eclipse SWT Team.
> I am the developer responsible for SWT Accessibility.
>
> Ken Perry of Blinksoft asked me if I could help with an issue brought up
> by Richard Baldwin regarding SWT being accessible but largely 
incompatible
> with Swing/AWT.
> I read several posts similar to this one:
>
> 
http://host.nfbnet.org/pipermail/blindmath_nfbnet.org/2012-January/004693.html

>
>
> I wrote an SWT Snippet that I hope you will find useful:
>
> 
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet361.java

>
> It shows how to host an AWT Canvas inside an SWT GUI, and use the GUI to
> initiate Java2D operations within the Canvas.
> I randomly chose rotation and translation of the image, but you should 
be
> able to modify the snippet to do whatever Java2D operations you are
> teaching.
> The "Print Image" button uses SWT to take a screen snapshot of the 
Canvas
> and print it to a printer.
> I had not heard of a printer that embosses images before, and I think 
that
> is really cool!
>
> I tried this snippet on Windows (XP) with JAWS (13) and on Mac OSX
> (Leopard) with VoiceOver, and on Linux (Ubuntu 10.04) with Orca and it
> worked on all 3 platforms.
> It should work with other platform versions and screen readers as well.
> The only glitch I encountered was on Windows, if the user tabs into the
> Canvas, they can't tab back out.
> They need to use the button mnemonics to traverse out of the Canvas: 
alt+o
> for Open, alt+x and alt+y for translating X and Y, alt+r for Rotate, and
> alt+p for Print.
> This was not an issue on Mac or Linux.
>
> I cannot solve the deeper issues, like making SWT and AWT graphics
> interchangeable without performance penalties (there are technical
> issues),
> or improving SWT's graphics support to the level of Java2D or more (we 
are
> a very small and very busy team, and we simply do not have the 
manpower).
> Hopefully this snippet will give you a work-around that is both 
accessible
> and teaches the math you want to teach.
>
> Carolyn
> _______________________________________________
> Blindmath mailing list
> Blindmath at nfbnet.org
> http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
> To unsubscribe, change your list options or get your account info for
> Blindmath:
> 
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/mwhapples%40aim.com
>
>
>
> _______________________________________________
> Blindmath mailing list
> Blindmath at nfbnet.org
> http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
> To unsubscribe, change your list options or get your account info for
> Blindmath:
>
> 
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/carolyn_macleod%40ca.ibm.com

>
>
>
>
> _______________________________________________
> Blindmath mailing list
> Blindmath at nfbnet.org
> http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
> To unsubscribe, change your list options or get your account info for
> Blindmath:
>
> 
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/baldwin%40dickbaldwin.com

>



-- 
Richard G. Baldwin (Dick Baldwin)
Home of Baldwin's on-line Java Tutorials
http://www.DickBaldwin.com

Professor of Computer Information Technology
Austin Community College
(512) 223-4758
mailto:Baldwin at DickBaldwin.com
http://www.austincc.edu/baldwin/
_______________________________________________
Blindmath mailing list
Blindmath at nfbnet.org
http://nfbnet.org/mailman/listinfo/blindmath_nfbnet.org
To unsubscribe, change your list options or get your account info for 
Blindmath:
http://nfbnet.org/mailman/options/blindmath_nfbnet.org/carolyn_macleod%40ca.ibm.com




-------------- next part --------------
A non-text attachment was scrubbed...
Name: FakeEmbeddedJFrame.java
Type: application/octet-stream
Size: 2208 bytes
Desc: not available
URL: <http://nfbnet.org/pipermail/blindmath_nfbnet.org/attachments/20120223/4add85f3/attachment.obj>


More information about the BlindMath mailing list