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

The following examples show how to use javax.swing.JComponent#getToolTipLocation() . 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
Source File: ComponentToolTipManager.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @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
Source File: ComponentToolTipManager.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: ComponentToolTipManager.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @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
Source File: ComponentToolTipManager.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

}