diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java index 0d3625b1..c4f983be 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java @@ -46,30 +46,11 @@ public class CellHintPopupListener extends MouseInputAd private I lastIndex; private Popup popup; - private boolean respectCellHeight = false; - private boolean respectCellWidth = true; - public CellHintPopupListener(final IndexedCellContainer cellContainer) { this.cellContainer = cellContainer; this.popupComponent = new PopupComponent(this); } - public void setRespectCellHeight(final boolean respectCellHeight) { - this.respectCellHeight = respectCellHeight; - } - - public void setRespectCellWidth(final boolean respectCellWidth) { - this.respectCellWidth = respectCellWidth; - } - - public boolean isRespectCellHeight() { - return respectCellHeight; - } - - public boolean isRespectCellWidth() { - return respectCellWidth; - } - public void install() { JComponent comp = cellContainer.getComponent(); comp.addMouseListener(this); @@ -160,11 +141,14 @@ public class CellHintPopupListener extends MouseInputAd boolean ltr = cellContainer.getComponent().getComponentOrientation().isLeftToRight(); popupComponent.setBorderInsets(1, 1, 1, 1); - if (isRespectCellWidth()) { - calculatePopupWidth(cellBounds, visibleBounds, rect, ltr); - } - if (isRespectCellHeight()) { + // Wen only support showing either a horizontal or vertical completion of the cell + // Calculate which portion would be bigger. + int hiddenVerticalSpace = Math.abs(cellBounds.width - visibleBounds.width); + int hiddenHorizontalSpace = Math.abs(cellBounds.height - visibleBounds.height); + if (hiddenHorizontalSpace > hiddenVerticalSpace) { calculatePopupHeight(cellBounds, visibleBounds, rect); + } else { + calculatePopupWidth(cellBounds, visibleBounds, rect, ltr); } if (!addBorder) { popupComponent.setBorderInsets(0, 0, 0, 0); @@ -189,11 +173,11 @@ public class CellHintPopupListener extends MouseInputAd if (upperDiff >= lowerDiff) { rect.y = visibleBounds.y + visibleBounds.height; rect.height = upperDiff; - popupComponent.setBottom(0); + popupComponent.setTop(0); } else { rect.y = cellBounds.y; rect.height = lowerDiff; - popupComponent.setTop(0); + popupComponent.setBottom(0); } } }