Swing Menu Painting, 2D Demo

J

Jesse Pavel

Hello,

I'm having a problem with the text of Swing menus being painted properly
when a lot of other drawing operations are being performed. An example
will make it clearer:

In the Java2D demo that comes with the JDK (in the demo/jfc/Java2D direcotory)
I run the BezierCurve demonstration, and if I reduce the animation delay enough,
menus don't paint properly. Clicking on the Options menu, for instance, clears a
gray box on the screen, but the menu items are not drawn unless I hover the
mouse cursor on top of them.

Looking at the code for the demos, I see that the animation works by spawning
a separate thread which in turn calls the repaint() method of the component that
is drawn upon (the Surface). repaint(), if I understand it correctly, appends
an event on the Swing queue, which will be processed by the event dispatch
thread in its turn. I am guessing that if the events are queued faster than
they can be processed, Swing is not getting the chance to paint the menu items,
which perhaps it does only when no events are pending?

Does anyone have an idea on how to fix this problem? Can one ensure that UI-
generated events bypass certain thread-generated events?

Thanks for any help,
Jesse
 
A

Andrew Thompson

Jesse said:
Hello,

I'm having a problem with the text of Swing menus being painted
properly
when a lot of other drawing operations are being performed. An example
will make it clearer:

In the Java2D demo that comes with the JDK (in the demo/jfc/Java2D
direcotory) I run the BezierCurve demonstration,

Which one?
http://java.sun.com/products/java-media/2D/samples/suite/index.html
The first one I sam mentions this,
but it does not look like you describe.
http://java.sun.com/products/java-media/2D/samples/suite/Arcs_Curves/BezierA
nim.html
 
J

Jesse Pavel

Andrew Thompson said:

To get the behavior I described, one needs to run the demonstration that
ships with the JDK, because it uses menus, whereas the applet versions
do not. In my Sun distribution of the JDK, the appropriate demo is located

j2sdk1.4.2_03/demo/jfc/Java2D/Java2Demo.jar

Thanks,
Jesse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top