Index: [thread] [date] [subject] [author]
  From: Michael Abernethy <mna@duke.edu>
  To  : 
  Date: Tue, 13 Apr 1999 22:38:30 -0400

Re: bouncing

 when you just used the addMouseListener(), you were actually registering 
the MouseListener with the Applet class.  Then, you add the Playpen on 
top of the Applet.  This means that any mouse clicks that occur in your 
applet are actually being sent to the Playpen, which "doesn't care" about 
them. 

 when you used the myPlaypen.addMouseListener(), you were registering the 
MouseListener with the Playpen, and suddenly, the Playpen starting 
"caring" about the mouse clicks.

> 
> I fixed the problem.  What I did is:  
>  
>   myPlaypen.addMouseListener(  same code as below)
> 
> rather than "addMouseListener()" in MyApplet.java. 
> 
> Any idea why this code works and my previous one won't?
> 
>  
> > could anyone help me figure out why this piece of code won't work?
> > 
> >  addMouseListener( new MouseAdapter(){	
> >        public void mouseClicked(MouseEvent e)
> > 	{
> > 	  myPlaypen.addBall(images);
> > 	}
> >       }
> > 			);
> > 
> > This is in MyApplet.java.  What I am trying to do here is to add a ball 
> > whenever the mouse is clicked.  But nothing happened when the mouse is 
> > clicked.  
> > 
> > 
> > 
> > 
> 
> 

Mike Abernethy
www.duke.edu/~mna
IBM Club Cyberblue - www.cybrblu.ibm.com



Index: [thread] [date] [subject] [author]