Re: Weird Problem in using MouseListener

From: Ian Shef (invalid_at_avoiding.spam)
Date: 02/19/04


Date: Thu, 19 Feb 2004 19:23:48 GMT

mintiSPAMBLOCK@yahoo.com (Minti) wrote in news:e87fc4b0.0402021802.7f5fcc26
@posting.google.com:

> Hi there all, I am having a weird problem in the following Applet
> code,
>
> <begin code>
<snip>
> <end code>
>
> The calls to System.out.println() are for debugging purposes only.
>
> 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.
>
>
> 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.
>
Calls to repaint queue up a request for paint to happen.
The paint does not happen immediately, so your listeners cannot depend upon
paint to clear out msg. The paint will occur sometime in the future.
However, multiple requests in the paint queue can be collected together, so
there is not neceesarily a one-to-one correspondence between calls to
repaint and executions of paint.

It is time to come up with a new plan of how to arrange your program.

Good Luck!

-- 
Ian Shef     805/F6      *    These are my personal opinions    
Raytheon Company         *    and not those of my employer.
PO Box 11337             * 
Tucson, AZ 85734-1337    * 


Relevant Pages

  • Re: Simple Problem - Question from Book
    ... Sonia, ... >>painting is handled by the paint method, which is turn calls things like ... > that will help an elementary school student learn multiplication. ... > on the applet and ask another multiplication question. ...
    (comp.lang.java.help)
  • Re: Weird Problem in using MouseListener
    ... > clicked the applet shows MouseRelasedMouseClicked, ... > paint method works. ... Calls to repaint queue up a request for paint to happen. ... However, multiple requests in the paint queue can be collected together, so ...
    (comp.lang.java)
  • Re: JPanel not visible in JApplet
    ... drawing is done by paint() and not init(). ... called when your applet is first invoked. ... the the Panel was painted. ...
    (comp.lang.java)
  • refreshing 2D Graphics screen problem
    ... The following program is an applet that reads a number from a file 10 ... that the method paint is performed. ... public class Shapes extends JApplet { ...
    (comp.lang.java)
  • Re: how and when components get their own size?
    ... First access of the applet is working fine. ... without closing the browser) and hitting again the applet's page the applet crashes because ... Displaying applet's page always causes init() and start, ... them in paint() or paintComponentmethod of custom component. ...
    (comp.lang.java.gui)