Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 491
  • Last Modified:

multiline tool tip text

I need to have a multiline tooltip text...this is to represent the address of a person as the tool tip when the mouse is moved on to it.


In general we  have tool tip text of single line and that extends tooo long for the complete address.so i need multiple line tooltip text.
0
sanjay_thakur
Asked:
sanjay_thakur
1 Solution
 
poluruCommented:
u can pass the html to setToolTipText()
like
object.setToolTipText("<html><font color='red'>Chandra Poluru,<br>Hyderabad,<br>A.P..</font></html>");
0
 
OviCommented:
see SwingSet2 demo which comes with your JDK
0
 
tomboshellCommented:
You will have to customize your own solution.  According to the Javadocs, you will have to "override JComponent's createToolTip method and use a subclass of this class"  'This class' being the JToolTip class.  So, create a new class extending the JToolTip class and then write your own implementation of the method 'setTipText(String tip)'.  You might have to include a line break character.

But I would wonder if using a mouseMotionListener and a JDialog or JPopupMenu wouldn't be better.  Then you write a listener and add it to a component that listens if the mouse is over an area, if over that area then the dialog/pop-up appears and then disappears.  This would be ideal if you want to offer the option of selecting that address to be inserted automatically.  

Hope I didn't confuse too much,
Tom
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now