Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-20-2008, 05:56 AM
Member
 
Join Date: Apr 2008
Posts: 2
gtraylo is on a distinguished road
Hovering mouse over a button and painting
The following code is what I have to try to paint a rectangle when ever I hover over a button. This rectangle will show a brief description of what the button will do. I'm doing something similar when pressing the help button and hovering over something a description in a rectangle shows up. But I cannot get the paint method to work. Can anyone tell me what I need to do to fix this.
Code:
public void mouseMoved(MouseEvent e) { //System.out.println("asdf"); showMessage("Test"); } private void showMessage(String string) { public void paint(Graphics g) { g.fillRect(25, 20, 20, 20); g.drawString("Hello", 25, 20); } //System.out.println(string); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-21-2008, 07:00 PM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 839
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)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-24-2008, 10:33 AM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 386
Zosden is on a distinguished road
why not use ToolTextTip it does what ur trying to do, but a lot easier
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse dragg not working Preethi AWT / Swing 1 02-08-2008 05:51 AM
The mouse and the cheese Don Quixote Java 2D 4 08-15-2007 11:55 PM
mouse over on JButton gradon Java Applets 1 08-04-2007 06:50 AM
Use the mouse position susan Java Applets 1 07-29-2007 12:10 AM
Mouse over JButton sandor AWT / Swing 1 05-17-2007 10:15 PM


All times are GMT +3. The time now is 08:36 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org