Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Swing Menu Painting, 2D Demo

Reply
Thread Tools

Swing Menu Painting, 2D Demo

 
 
Jesse Pavel
Guest
Posts: n/a
 
      02-15-2004
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
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      02-15-2004
Jesse Pavel wrote:
> 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-me...ite/index.html
The first one I sam mentions this,
but it does not look like you describe.
http://java.sun.com/products/java-me...Curves/BezierA
nim.html

--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology


 
Reply With Quote
 
 
 
 
Jesse Pavel
Guest
Posts: n/a
 
      02-18-2004
"Andrew Thompson" <(E-Mail Removed)> wrote in message news:<MoJXb.59910$(E-Mail Removed)>...

> Which one?
> http://java.sun.com/products/java-me...ite/index.html
> The first one I sam mentions this,
> but it does not look like you describe.
> http://java.sun.com/products/java-me...Curves/BezierA
> nim.html


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javax.swing.Popup, javax.swing.PopupFactory lizard Java 0 01-30-2006 09:34 PM
Swing Model Classes Updating Swing Components on a Thread Other Than AWT mkrause Java 0 05-06-2005 04:32 PM
Java 1.2 Swing vs. Java 1.5 Swing Big Daddy Java 2 04-16-2005 01:14 PM
wxPython demo /Process does not open new demo Andy Leszczynski Python 1 02-18-2005 06:03 PM
PyOpenGL demo in wxPython demo crashes F. GEIGER Python 9 05-03-2004 04:43 PM



Advertisments