
Here is the simple code for showing a custom tooltip..
Timer schi=null;
I have taken a schi instance level timer type variable to set when the tooltip it has to hide.
int delay=5000;
int period=10000;
These Two are instance level variable defined for the after that delay timer will execute and period is after each 10000 It will Execute
ttip is a Tooltip instance variable
on jbutton action perfomed dynamically popping up the tooltip with this code.
try{schi.cancel();}
catch(Exception es)
{
System.out.println(""+es);
}
Point pp=evt.getLocationOnScreen();
try{
ttip.hide();}catch(Exception ed){
System.out.println("how");
}
ttip=new ToolTip("Text is here");
ttip.setText(jTextField1.getText());
ttip.setSize(200, 200);
ttip.setLocation(pp);
ttip.show();
hidema();_________________________
_____________________
hidema() is a function in which schi timer is defined
code inside hidema is actually used to hide the tooltip
void hidema()
{
try{
schi=new Timer();
schi.scheduleAtFixedRate(new TimerTask()
{
public void run()
{
// here stops
ttip.hide();
}
},elay,eriod);
//schi.cancel();
}catch(NullPointerException npe)
{
System.out.println("got isded"+npe);
}
}
===========================
==========================
If you want to download full source
==========================
==========================
Read More......