• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

beginner / mouse listener, ears are plugged

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic