import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Point;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolTip;
public class Main {
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;
}
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);
}
}
|