METHODS OF TOOL TIP TEXT:
setToolTipText(String)
String getToolTipText()
String getToolTipText(MouseEvent)
Point getToolTipLocation(MouseEvent)
As you can see we have used first constructor to set tooltip text.Second constructor is used get tool tip text of a component the use of second constructor is also same but it's used when there are multi part component such as jtable then it will only return that text that is associated with mouse event.
import java.awt.*;
class tab extends JFrame
{
JButton jb;
tab()
{
super();
setTitle("Tool Tip Text");
setSize(250, 300);
setVisible(true);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jb =new JButton("BUTTON");
FlowLayout f=new FlowLayout();
setLayout(f);
add(jb);
jb.setToolTipText("This is ToolTip Text.");
}
}
class nbutt
{
public static void main(String args[])
{
tab x= new tab();
}
}
CODING:
import javax.swing.*;import java.awt.*;
class tab extends JFrame
{
JButton jb;
tab()
{
super();
setTitle("Tool Tip Text");
setSize(250, 300);
setVisible(true);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jb =new JButton("BUTTON");
FlowLayout f=new FlowLayout();
setLayout(f);
add(jb);
jb.setToolTipText("This is ToolTip Text.");
}
}
class nbutt
{
public static void main(String args[])
{
tab x= new tab();
}
}
No comments:
Post a Comment