456 |
*/ |
*/ |
457 |
void showTip() |
void showTip() |
458 |
{ |
{ |
459 |
if (!enabled || currentComponent == null |
if (!enabled || currentComponent == null || !currentComponent.isEnabled() |
460 |
|| (currentTip != null && currentTip.isVisible())) |
|| (currentTip != null && currentTip.isVisible())) |
461 |
return; |
return; |
462 |
|
|
465 |
currentTip = ((JComponent) currentComponent).createToolTip(); |
currentTip = ((JComponent) currentComponent).createToolTip(); |
466 |
|
|
467 |
Container parent = currentComponent.getParent(); |
Container parent = currentComponent.getParent(); |
|
if (parent instanceof JPopupMenu) |
|
|
setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled()); |
|
|
|
|
|
// Moves currentPoint to an appropriate place |
|
468 |
Point p = currentPoint; |
Point p = currentPoint; |
469 |
Dimension dims = currentTip.getPreferredSize(); |
Dimension dims = currentTip.getPreferredSize(); |
470 |
Rectangle bounds = currentComponent.getBounds(); |
Rectangle bounds = currentComponent.getBounds(); |
471 |
p.x = bounds.width - dims.width; |
p.x += bounds.width - dims.width; |
472 |
p.y = bounds.height; |
p.y = bounds.height; |
473 |
|
|
474 |
|
if (parent instanceof JPopupMenu) |
475 |
|
setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled()); |
476 |
|
|
477 |
if (isLightWeightPopupEnabled()) |
if (isLightWeightPopupEnabled()) |
478 |
{ |
{ |
479 |
|
if (p.x < parent.getBounds().x) |
480 |
|
p.x = 0; |
481 |
|
|
482 |
JLayeredPane pane = ((JRootPane) SwingUtilities. |
JLayeredPane pane = ((JRootPane) SwingUtilities. |
483 |
getAncestorOfClass(JRootPane.class, currentComponent)). |
getAncestorOfClass(JRootPane.class, currentComponent)). |
484 |
getLayeredPane(); |
getLayeredPane(); |
509 |
} |
} |
510 |
else if (currentComponent.isShowing()) |
else if (currentComponent.isShowing()) |
511 |
{ |
{ |
512 |
|
Rectangle b = parent.getBounds(); |
513 |
|
if (p.x + dims.width > b.x + b.width) |
514 |
|
p.x = b.x - dims.width; |
515 |
|
|
516 |
SwingUtilities.convertPointToScreen(p, currentComponent); |
SwingUtilities.convertPointToScreen(p, currentComponent); |
517 |
tooltipWindow = new JDialog(); |
tooltipWindow = new JDialog(); |
518 |
tooltipWindow.setContentPane(currentTip); |
tooltipWindow.setContentPane(currentTip); |