Thursday, July 8, 2010

Setting ToolTip and Icon  

0 comments

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();
}
}

What next?

You can also bookmark this post using your favorite bookmarking service:

Related Posts by Categories



0 comments: to “ Setting ToolTip and Icon

Extension Factory Builder