Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display hint message when put mouse over a button  RSS feed

 
rose deng
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I want to do following thing: when put mouse over button,some hint message will appear,when mouse left,the message disappear.
i know it's easy to do if use Swing,but i must use just Awt.
Give me help and thanks for your help a lot.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rose,
This is going to be really hard to do just like the ToolTips in Swing with only AWT...
Personally, what I would do is make a TextArea that only displays help text down in the corner of my app somewhere, and then use a MouseMotionListener to detect what component I am over and send strings to the TextArea...
You could try and make ToolTips like the Swing ToolTips by using a MouseMotionListener, detecting what component you are over, and painting a rectangle and strings over the components on the screen. However, this is going to be much more difficult... you are going to have to ( at least ) mess with fonts, and possibly have to make special components so that you can paint over them... It's possible to do ( especially since the programmers at Sun did it in Swing ), it's just a bit more in depth...
HTH,
-Nate
 
rob armstrong
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your saying you can't have a rectangle or shape and have it displayed in a JPanel that has tooltips?
JPanel added to JFrame

Or do we have to make our own tooltips.
I was hoping just to extend JComponent for the shape and override paintComponent(Graphics g)

thanks roba
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!