Example usage for javax.swing JLabel setToolTipText

List of usage examples for javax.swing JLabel setToolTipText

Introduction

In this page you can find the example usage for javax.swing JLabel setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:Main.java

public static void main(String[] args) {
    String html = "<html><body>" + "<h1>Header</h1>" + "<img src='http://www.java2s.com/style/download.png' "
            + "width='160' height='120'>";
    JLabel label = new JLabel("Point at me!");
    label.setToolTipText(html);
    JOptionPane.showMessageDialog(null, label);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    final String html = "<html><body>" + "<img src='" + "http://www.java2s.com/style/download.png"
            + "' width=160 height=120> " + "<img src='" + "http://www.java2s.com/style/download.png"
            + "' width=160 height=120>" + "<p>Message!";

    JLabel hover = new JLabel("Point at me!");
    hover.setToolTipText(html);
    JOptionPane.showMessageDialog(null, hover);

}

From source file:HtmlToolTipDemo.java

public static void main(String[] a) {
    JFrame mainFrame = new JFrame();

    JLabel label = new JLabel("label");

    label.setToolTipText("<html>First line<br>Second Line</html>");
    mainFrame.getContentPane().add(label);

    mainFrame.setSize(100, 100);/*  w  w w  .  jav a  2  s.c  o m*/

    mainFrame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("Username :", JLabel.RIGHT);

    label.setToolTipText("A tool tip with me!");

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Tool Tip Demo");
    frame.setSize(200, 200);//from  w  w w. ja v a2s  . c  om
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("Hover on me!");

    label.setToolTipText("My JLabel Tool Tip");

    frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
    frame.getContentPane().add(label);

    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();
    JLabel label = new JLabel("Label with image in Tooltip!");
    label.setToolTipText("<html><img src=\"" + Main.class.getResource("tooltip.gif") + "\"> Tooltip ");
    label.setHorizontalAlignment(JLabel.CENTER);
    frame.setContentPane(label);/*from   www.  j a  v a 2  s  .  c  o m*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(100, 100, 200, 100);
    frame.setVisible(true);

}

From source file:Main.java

License:asdf

public static void main(String[] argv) {
    JLabel wonLabel = new JLabel() {
        public JToolTip createToolTip() {
            return new ImageToolTip();
        }//from   www  .  jav a  2  s.c om
    };
    wonLabel.setToolTipText("asdf");
}

From source file:LabelHeaderSample.java

public static void main(String args[]) {
    final Object rows[][] = { { "one", "1" }, { "two", "2" }, { "three", "3" } };
    JFrame frame = new JFrame("Label Header");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String headers[] = { "English", "#" };
    JTable table = new JTable(rows, headers);
    JScrollPane scrollPane = new JScrollPane(table);

    JLabel headerRenderer = new DefaultTableCellRenderer();
    String columnName = table.getModel().getColumnName(0);
    headerRenderer.setText(columnName);/*  w ww  . j ava2s. co m*/
    headerRenderer.setToolTipText("text");
    TableColumnModel columnModel = table.getColumnModel();
    TableColumn englishColumn = columnModel.getColumn(0);
    englishColumn.setHeaderRenderer((TableCellRenderer) headerRenderer);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    String rows[][] = { { "A", "a" }, { "B", "b" }, { "E", "e" } };
    String headers[] = { "Upper", "Lower" };

    JFrame frame = new JFrame("Tooltip Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTable table = new JTable(rows, headers);

    JLabel headerRenderer = new DefaultTableCellRenderer();
    String columnName = table.getModel().getColumnName(0);
    headerRenderer.setText(columnName);/*from w  ww  . ja va 2  s  . c o m*/
    headerRenderer.setToolTipText("Wave");

    TableColumnModel columnModel = table.getColumnModel();
    TableColumn column = columnModel.getColumn(0);
    column.setHeaderRenderer((TableCellRenderer) headerRenderer);

    JScrollPane scrollPane = new JScrollPane(table);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:SwingToolTipSample.java

public static void main(String args[]) {
    Object rows[][] = { { "one", "ichi - \u4E00" }, { "two", "ni - \u4E8C" }, { "three", "san - \u4E09" },
            { "four", "shi - \u56DB" }, { "five", "go - \u4E94" }, { "six", "roku - \u516D" },
            { "seven", "shichi - \u4E03" }, { "eight", "hachi - \u516B" }, { "nine", "kyu - \u4E5D" },
            { "ten", "ju - \u5341" } };
    Object headers[] = { "English", "Japanese" };
    JFrame frame = new JFrame("Tooltip Sample");
    JTable table = new JTable(rows, headers);

    JLabel headerRenderer = new DefaultTableCellRenderer();
    String columnName = table.getModel().getColumnName(0);
    headerRenderer.setText(columnName);/*from w  w w .jav  a  2  s .  c o m*/
    headerRenderer.setToolTipText("Wave");
    TableColumnModel columnModel = table.getColumnModel();
    TableColumn englishColumn = columnModel.getColumn(0);
    englishColumn.setHeaderRenderer((TableCellRenderer) headerRenderer);

    JScrollPane scrollPane = new JScrollPane(table);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}