Redirect Tooltips to a textComponent.
Hi,
I have a simple question. Let's suppose I define a tooltip on a JButton using button.setTooltipText("hi");
Now when the mouse is over the button, the tooltip is shown.
What I want is that instead of showing the small message, the message must be shown in a textcomponent. (like jtextarea).
How can I do that without implementing MouseListener and getting the tooltip and the set it to the right component ?
Is there any way to deal with the tooltip system ?
It's actually just a matter of overriding the getToolTipText(MouseEvent) method in a particular component.
For instance, if you wanted to change the behavior of the tool tip text on a JTable:
JTable jTable1 = new JTable(new DefaultTableModel(2,2)){
public String getToolTipText(MouseEvent e){
System.out.println(this.getToolTipText());
return null;
}
};
jTable1.setToolTipText("Tool Tip in the text window!");
Rather than doing a System.out, you could append to a text area, change a JLabel, or whatever else you want - getToolTipText() returns a string.