Swing Menu Painting, 2D Demo

Discussion in 'Java' started by Jesse Pavel, Feb 15, 2004.

  1. Jesse Pavel

    Jesse Pavel Guest

    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
    Jesse Pavel, Feb 15, 2004
    #1
    1. Advertising

  2. 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-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

    --
    Andrew Thompson
    * http://www.PhySci.org/ Open-source software suite
    * http://www.PhySci.org/codes/ Web & IT Help
    * http://www.1point1C.org/ Science & Technology
    Andrew Thompson, Feb 15, 2004
    #2
    1. Advertising

  3. Jesse Pavel

    Jesse Pavel Guest

    "Andrew Thompson" <> wrote in message news:<MoJXb.59910$>...

    > 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


    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
    Jesse Pavel, Feb 18, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    9
    Views:
    1,218
    F. GEIGER
    May 3, 2004
  2. matt

    Swing Painting Problems

    matt, Mar 28, 2007, in forum: Java
    Replies:
    2
    Views:
    350
  3. Kgbol
    Replies:
    4
    Views:
    1,136
  4. Evan

    Swing painting problems

    Evan, Mar 8, 2008, in forum: Java
    Replies:
    1
    Views:
    404
    Peter Duniho
    Mar 8, 2008
  5. Replies:
    10
    Views:
    8,516
    Roedy Green
    Apr 11, 2009
Loading...

Share This Page