Set the location of the tool tip in Java

Description

The following code shows how to set the location of the tool tip.

Example


 //w ww.  java2 s  .co m

import java.awt.Point;
import java.awt.event.MouseEvent;

import javax.swing.JButton;

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

    JButton button = new JButton("My Button") {
      public Point getToolTipLocation(MouseEvent event) {
        return new Point(getWidth() / 2, getHeight());
      }
    };

  }
}

The code above generates the following result.

Set the location of the tool tip in Java




















Home »
  Java Tutorial »
    Swing »




Action
Border
Color Chooser
Drag and Drop
Event
Font Chooser
JButton
JCheckBox
JComboBox
JDialog
JEditorPane
JFileChooser
JFormattedText
JFrame
JLabel
JList
JOptionPane
JPasswordField
JProgressBar
JRadioButton
JScrollBar
JScrollPane
JSeparator
JSlider
JSpinner
JSplitPane
JTabbedPane
JTable
JTextArea
JTextField
JTextPane
JToggleButton
JToolTip
JTree
Layout
Menu
Timer