diff --git a/freeplane/src/main/java/org/freeplane/view/swing/map/FreeplaneTooltip.java b/freeplane/src/main/java/org/freeplane/view/swing/map/FreeplaneTooltip.java index 263b34caf3..11f36de1f3 100644 --- a/freeplane/src/main/java/org/freeplane/view/swing/map/FreeplaneTooltip.java +++ b/freeplane/src/main/java/org/freeplane/view/swing/map/FreeplaneTooltip.java @@ -78,7 +78,7 @@ public Dimension getPreferredSize() { @Override public void layout() { final Component renderer = getComponent(0); - renderer.setSize(getPreferredSize()); + renderer.setSize(getSize()); super.layout(); } diff --git a/freeplane/src/main/java/org/freeplane/view/swing/map/NodeTooltipManager.java b/freeplane/src/main/java/org/freeplane/view/swing/map/NodeTooltipManager.java index e0b2c33517..0069c9f064 100644 --- a/freeplane/src/main/java/org/freeplane/view/swing/map/NodeTooltipManager.java +++ b/freeplane/src/main/java/org/freeplane/view/swing/map/NodeTooltipManager.java @@ -2,9 +2,11 @@ import java.awt.Component; +import java.awt.Dimension; import java.awt.GridLayout; import java.awt.KeyboardFocusManager; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -157,18 +159,25 @@ private void showTipWindow() { return; tip = insideComponent.createToolTip(); tip.setTipText(toolTipText); - final JComponent nearComponent = insideComponent; focusOwnerRef = new WeakReference(focusOwner); tipPopup = new JPopupMenu(); tipPopup.setLayout(new GridLayout(1, 1)); tipPopup.add(tip); mouseInsideTooltipListener = new MouseInsideListener(tipPopup); - final Component placedComponent = tipPopup; - Point location = UITools.findBestLocation(placedComponent, nearComponent); - SwingUtilities.convertPointFromScreen(location, nearComponent); - tipPopup.show(nearComponent, location.x, location.y); - focusOwner.requestFocusInWindow(); - exitTimer.start(); + final Rectangle desktopBounds = UITools.getAvailableScreenBounds(insideComponent); + final Dimension popupPreferredSize = tipPopup.getPreferredSize(); + final Point desiredLocation = new Point(0, insideComponent.getHeight()); + SwingUtilities.convertPointToScreen(desiredLocation, insideComponent); + int popupAllowedHeight = desktopBounds.y + desktopBounds.height - desiredLocation.y; + if(popupAllowedHeight > 0) { + Dimension popupSize = new Dimension( + popupPreferredSize.width, + Math.min(popupAllowedHeight, popupPreferredSize.height)); + tipPopup.setPreferredSize(popupSize); + tipPopup.show(insideComponent, 0, insideComponent.getHeight()); + focusOwner.requestFocusInWindow(); + exitTimer.start(); + } } private void hideTipWindow() {