aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes beginner / mouse listener, ears are plugged Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "beginner / mouse listener, ears are plugged" Watch "beginner / mouse listener, ears are plugged" New topic
Author

beginner / mouse listener, ears are plugged

ed jones
Greenhorn

Joined: Oct 01, 2008
Posts: 11
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

Joined: Oct 13, 2005
Posts: 39851
    
  28
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

Joined: Jun 09, 2003
Posts: 4632
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: beginner / mouse listener, ears are plugged