Java Code Examples for javax.swing.JComponent#getToolTipLocation()

The following examples show how to use javax.swing.JComponent#getToolTipLocation() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * 
 * @param event
 */
private void initiateToolTip(MouseEvent event) {

  JComponent component = (JComponent) event.getSource();
  String newToolTipText = component.getToolTipText(event);
  newToolTipComponent = ((ComponentToolTipProvider) component).getCustomToolTipComponent(event);

  if (newToolTipComponent == null)
    return;

  component.removeMouseMotionListener(moveBeforeEnterListener);

  Point location = event.getPoint();
  // ensure tooltip shows only in proper place
  if (location.x < 0 || location.x >= component.getWidth() || location.y < 0
      || location.y >= component.getHeight()) {
    return;
  }

  component.removeMouseMotionListener(this);
  component.addMouseMotionListener(this);

  mouseEvent = event;
  toolTipText = newToolTipText;
  preferredLocation = component.getToolTipLocation(event);
  insideComponent = component;

  showTipWindow();
}
 
Example 2
/**
 * Checks to see if the tooltip needs to be changed in response to the MouseMoved event
 * <code>event</code>.
 */
private void checkForTipChange(MouseEvent event) {
  JComponent component = (JComponent) event.getSource();
  String newText = component.getToolTipText(event);
  Point newPreferredLocation = component.getToolTipLocation(event);

  if (newText == null) {
    reset();
    hideTipWindow();
    return;
  }
  if (newPreferredLocation == null)
    return;

  if ((newText.equals(toolTipText))) {
    return;
  }

  newToolTipComponent = ((ComponentToolTipProvider) component).getCustomToolTipComponent(event);

  if (newToolTipComponent == null)
    return;

  toolTipText = newText;
  mouseEvent = event;
  preferredLocation = newPreferredLocation;
  hideTipWindow();
  showTipWindow();

}
 
Example 3
/**
 * 
 * @param event
 */
private void initiateToolTip(MouseEvent event) {

  JComponent component = (JComponent) event.getSource();
  String newToolTipText = component.getToolTipText(event);
  newToolTipComponent = ((ComponentToolTipProvider) component).getCustomToolTipComponent(event);

  if (newToolTipComponent == null)
    return;

  component.removeMouseMotionListener(moveBeforeEnterListener);

  Point location = event.getPoint();
  // ensure tooltip shows only in proper place
  if (location.x < 0 || location.x >= component.getWidth() || location.y < 0
      || location.y >= component.getHeight()) {
    return;
  }

  component.removeMouseMotionListener(this);
  component.addMouseMotionListener(this);

  mouseEvent = event;
  toolTipText = newToolTipText;
  preferredLocation = component.getToolTipLocation(event);
  insideComponent = component;

  showTipWindow();
}
 
Example 4
/**
 * Checks to see if the tooltip needs to be changed in response to the MouseMoved event
 * <code>event</code>.
 */
private void checkForTipChange(MouseEvent event) {
  JComponent component = (JComponent) event.getSource();
  String newText = component.getToolTipText(event);
  Point newPreferredLocation = component.getToolTipLocation(event);

  if (newText == null) {
    reset();
    hideTipWindow();
    return;
  }
  if (newPreferredLocation == null)
    return;

  if ((newText.equals(toolTipText))) {
    return;
  }

  newToolTipComponent = ((ComponentToolTipProvider) component).getCustomToolTipComponent(event);

  if (newToolTipComponent == null)
    return;

  toolTipText = newText;
  mouseEvent = event;
  preferredLocation = newPreferredLocation;
  hideTipWindow();
  showTipWindow();

}