Setting ToolTip and Icon
Adding Icons and ToolTips
Tooltips are shot information messages which are displayed when your mouse pointer rests at some components.That is if suppose your mose pointer is at a button whose tooltiop is set as "click here" the if your pointer comes over button the a small message will appear saying "click here".
For setting ToolTip we can use setToolTipText() method of JComponent class.
ToolTip Example:-
// tooltip.java
import javax.swing.*;
public class tooltip
{
public static void main(String a[])
{
JFrame frm=new JFrame("ToolTip Demo");
JPanel panel=new JPanel();
JLabel labeltool=new JLabel("ToolTio DemoPlace mouse over it");
labeltool.setToolTipText("This is ToolTip");
panel.add(labeltool);
frm.getContentPane().add(panel);
frm.setVisible(true);
frm.pack();
}
}
SettingIcon Example:-
// settingicon.java![]()
import java.awt.*;
import javax.swing.*;
public class settingicon
{
public static void main(String a[])
{
JFrame frm=new JFrame("Setting Icon Demo");
JPanel panel=new JPanel();
JLabel label=new JLabel(new ImageIcon("BAK.png"));
panel.add(label);
frm.getContentPane().add(panel);
frm.setVisible(true);
frm.pack();
}
}


















0 comments:
Post a Comment
Post a Comment