Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Set the location of the tool tip such that its nw corner coincides with the bottom center of the button

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