JLabel: setToolTipText(String text) : JLabel « javax.swing « Java by API






JLabel: setToolTipText(String text)

 

 
import java.awt.FlowLayout;
import java.awt.HeadlessException;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main extends JFrame {
  public Main() throws HeadlessException {
    setSize(150, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout());

    JLabel label1 = new JLabel("Username :", JLabel.RIGHT);
    JLabel label2 = new JLabel("Password :", JLabel.RIGHT);
    JLabel label3 = new JLabel("Confirm Password :", JLabel.RIGHT);
    JLabel label4 = new JLabel("Remember Me!", JLabel.LEFT);
    JLabel label5 = new JLabel("Hello.", JLabel.CENTER);

    label5.setVerticalAlignment(JLabel.TOP);
    label5.setToolTipText("A tool tip with me!");

    getContentPane().add(label1);
    getContentPane().add(label2);
    getContentPane().add(label3);
    getContentPane().add(label4);
    getContentPane().add(label5);
  }

  public static void main(String[] args) {
    new Main().setVisible(true);
  }
}

   
  








Related examples in the same category

1.JLabel.BOTTOM
2.JLabel.CENTER
3.JLabel.LEFT
4.JLabel.RIGHT
5.JLabel.TOP
6.new JLabel(Icon icon)
7.new JLabel(Icon i, int alignment)
8.new JLabel(String htmlString) (Multi-line Label)
9.new JLabel(String text, int horizontalAlignment)
10.new JLabel(String text, Icon icon, int horizontalAlignment)
11.JLabel: addMouseMotionListener(MouseMotionListener l)
12.JLabel: getTransferHandler()
13.JLabel: setBoder(Border border)
14.JLabel: setBounds(int x, int y, int width, int height)
15.JLabel: setDisplayedMnemonic(int key) (KeyEvent.VK_U)
16.JLabel: setDisplayedMnemonicIndex(int index)
17.JLabel: setLabelFor(Component c)
18.JLabel: setText(String str)
19.JLabel: setHorizontalTextPosition(int align)
20.JLabel: setIcon(Icon icon)
21.JLabel: setOpaque(boolean isOpaque)
22.JLabel: setPreferredSize(Dimension preferredSize)
23.JLabel: setVerticalAlignment(int alignment)
24.JLabel: setVerticalTextPosition(int align)
25.extends JLabel