Re: Weird Problem in using MouseListener

From: Matt Humphrey (matth_at_ivizNOSPAM.com)
Date: 02/03/04


Date: Mon, 2 Feb 2004 22:01:46 -0500


"Minti" <mintiSPAMBLOCK@yahoo.com> wrote in message
news:e87fc4b0.0402021802.7f5fcc26@posting.google.com...
> Hi there all, I am having a weird problem in the following Applet
> code,
>
> <begin code>
<snip code>

> The problem is that when the applet is running, whenever mouse is
> clicked the applet shows MouseRelasedMouseClicked, even though I set
> the msg to "" whenever paint is called, the line with
> System.out.println(msg) in mouseReleased() shows that somehow the call
> to repaint() just did not occur, Am I missing any point on how the
> paint method works.

Yes, you're missing the point. Repaint does not call paint. Repaint informs
the rendering system that a particular region needs to be updated. You can
call repaint many times and the region may be marked only once. (In fact, if
the region is obscured it may not even get repainted at all, which is why
paint shouldn't have side-effects.) Moreover, the mouse events are occuring
in the UI thread, which is also used for painting. The painting will occur
at best after the current events are finished--you really wouldn't want to
deal with the complexity of an action thread running in parallel with your
painting thread. Finally, part of the explanation of your result is that
while mousePressed and mouseClicked say msg += " more message", the
mouseReleased handler simply says msg = "mouseReleased", which makes it drop
the mouse pressed message.

> I belive it is possibly because of the paint queue, that might be
> maintained and from which only the most recent call to paint is
> executed.

There is no paint queue. Painting is done from the same UI thread that
handles event dispatching.

Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/



Relevant Pages

  • Re: Best way to create graphical window inside a dialog?
    ... InvalidateRect and actually getting your paint message. ... Also, because you are painting what you describe as a tilemap, you dont want ... detected as a reason to invalidate and repaint. ... accidentally treat my DialogProc as a WindowProc. ...
    (microsoft.public.win32.programmer.ui)
  • Re: simple question
    ... >I was just wondering if there was a way to paint in a MouseDown ... In class we only learned about the paint method, ... What you would normally do in use a repaint with a clipregion to cause ... painting. ...
    (comp.lang.java.gui)
  • John Hwangs Painting Notes, 2006
    ... By no means should this be considered the final word in painting miniatures. ... Dark vs Bright strongly affects your overall visual style. ... If you're going to paint, you'll need the appropriate supplies: quality brushes, acrylic paint, spray primer, epoxy putty or SGT, glue, pins, hobby knife, and "needle" files. ... As you'll be using the same set of brushes for *all* of your minis, this is *not* the place to try and "save" money; if anything, double up on the brush sizes you use most often so that they last just that much longer. ...
    (rec.games.miniatures.warhammer)
  • Vandal Hussains Art Exhibit Vandalized!
    ... If spraying of paint can ... be called art for Hussain, why not spraying of black paint? ... Hindu activists with financial and other links to political extremists ... and sprayed the painting called Durga with black paint. ...
    (soc.culture.indian)
  • Re: Playfield cleaning - paint flaking off
    ... that may be worth it. ... and your entire playfield is compromised. ... of paint. ... I am getting ready to repaint the wings of my "birdman" as well...if ...
    (rec.games.pinball)