Example usage for javax.swing JButton setToolTipText

List of usage examples for javax.swing JButton setToolTipText

Introduction

In this page you can find the example usage for javax.swing JButton 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[] argv) throws Exception {
    JButton component = new JButton();
    component.setToolTipText("<html>" + "This is a" + "<br><i>" + "tool tip" + "</i></html>");

}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Test");
    button.setToolTipText("Help text for the button");

    JOptionPane.showMessageDialog(null, button);
}

From source file:ButtonTipTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tool Tips");
    Container contentPane = frame.getContentPane();
    JButton b = new JButton("Button");
    b.setToolTipText("Go Away");
    contentPane.add(b, BorderLayout.NORTH);
    frame.setSize(300, 200);/*  w w  w.  j a  va  2s. c  o m*/
    frame.show();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton button = new JButton(new ImageIcon("image.gif"));
    button.setToolTipText("Button Name");

    button.getAccessibleContext().setAccessibleName("Button Name");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    String imageName = "file:image.jpg";
    component.setToolTipText("<html>Here is an image <img src=" + imageName + "></html>");

}

From source file:ToolTipDemo.java

License:asdf

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton b = new JButton("Hello, World");
    frame.add(b, "Center");
    b.setToolTipText("asdf");
    frame.setSize(300, 200);//from  ww  w  .  j  a v  a  2  s. c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JDialog f = new JDialog();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//  w ww  . j  a v a2  s  .c  o m
        }
    });

    JButton btOK = new JButton("Press Enter to click me, I am the default.");
    btOK.setToolTipText("Save and exit");
    f.getRootPane().setDefaultButton(btOK);

    JPanel p = new JPanel();
    p.add(btOK);
    p.add(new JButton("I am NOT the default."));
    f.getContentPane().add(p);

    f.pack();
    f.setSize(new Dimension(300, 200));

    f.setVisible(true);

}

From source file:DefaultButton.java

public static void main(String[] a) {
    JDialog f = new JDialog();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);// w  w  w.  j  ava  2 s .  c o m
        }
    });

    JButton btOK = new JButton("Press Enter to click me, I am the default.");
    btOK.setToolTipText("Save and exit");
    f.getRootPane().setDefaultButton(btOK);

    JPanel p = new JPanel();
    p.add(btOK);
    p.add(new JButton("I am NOT the default."));
    f.getContentPane().add(p);

    f.pack();
    f.setSize(new Dimension(300, 200));

    f.show();

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton button = new JButton("My Button") {
        public Point getToolTipLocation(MouseEvent event) {
            return null;
        }/*from www. j ava2 s .  c o  m*/
    };

    // Set the tool tip text
    button.setToolTipText("aString");
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JToolTip Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton b1 = new JButton("Button 1") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setForeground(Color.YELLOW);
            return tip;
        }/* w  w  w  .  j  ava  2  s .c o m*/

        public Point getToolTipLocation(MouseEvent event) {
            return new Point((event.getX() + 100), (event.getY() + 100));
        }
    };
    b1.setToolTipText("HELLO");
    frame.add(b1, BorderLayout.NORTH);
    frame.setSize(300, 150);
    frame.setVisible(true);
}