+
+ private Point lastp = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.swing.JComponent#getToolTipLocation(java.awt.event.MouseEvent)
+ */
+ public Point getToolTipLocation(MouseEvent event)
+ {
+ int x = event.getX(), w = getWidth();
+ int wdth = (w - x < 200) ? -(w / 2) : 5; // switch sides when tooltip is too
+ // close to edge
+ Point p = lastp;
+ if (!event.isShiftDown() || p == null)
+ {
+ p = (tooltipText != null && tooltipText.length() > 6) ? new Point(
+ event.getX() + wdth, event.getY() - 20) : null;
+ }
+ /*
+ * TODO: try to modify position region is not obcured by tooltip
+ */
+ return lastp = p;
+ }
+