View Single Post
  #2 (permalink)  
Old 04-21-2008, 08:00 PM
CaptainMorgan's Avatar
CaptainMorgan CaptainMorgan is offline
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
What do you mean it will not work? Are you receiving errors? Is the rectangle not showing? Also, your code is a bit strange... this is the first time I've seen the paint method as you've shown... someone correct me if I'm wrong.. but I don't think you can have a method definition inside of another one...move the paint method outside of the showMessage method can we see the whole class and/or how you're using it...
Code:
public void mouseMoved(MouseEvent e) { //System.out.println("asdf"); showMessage("Test"); } private void showMessage(String string) { //System.out.println(string); } public void paint(Graphics g) { g.fillRect(25, 20, 20, 20); g.drawString("Hello", 25, 20); }
I realize this isn't the answer you're looking for but have a good read at the Sun tutorial on Mouse-Motion and other events.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Reply With Quote