• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

beginner / mouse listener, ears are plugged

 
ed jones
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read alot of code on mouse listeners, and I'm still stuck

I've created a rectangle, and when the mouse is inside, and I click, I should see a response in the rectangle, but I don't?

thanks for your time

heres some of the code

[edit]Add code tags. CR[/edit]
[ October 17, 2008: Message edited by: Campbell Ritchie ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see anything wrong with the code.

What you are doing is setting xpos and ypos, but you are not doing anything with them.

Try putting this is your mousePressed() method, press your mouse, and see what happensPlease find the code button and use tags to maintain your indentation. This sort of thing is usually discussed in the Swing forum, so I think I ought to move you there.

[/edit]Spelling errors and change mouseDragged to mousePressed[/edit]
[ October 17, 2008: Message edited by: Campbell Ritchie ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a lot depends on what your classes are i.e. components etc.
assuming they are, the program is unlikely to print anything that can be seen.

you add a mouseListener to outsideFrame
you also add the mouseListener to 'extends GraphicsProgram' (whatever that is)
then you add outsideFrame to 'extends GraphicsProgram'

so the mouse will be clicking outsideFrame, but repaint() and paint()
belong to 'extends GraphicsProgram' which is perhaps covered by outsideFrame
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic