diff --git a/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java b/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java index 22136e1ec7f..d6488edacec 100644 --- a/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java +++ b/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java @@ -18,6 +18,7 @@ package forge.gui.deckeditor; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; @@ -266,12 +267,26 @@ public enum CDeckEditorUI implements CardContainer { this.tableView = tableView; } + private Component _getPopupRoot() { + Component root = SwingUtilities.getRoot(popupLabel); + if (null == root) { + // manually locate root ancestor (required on platforms that don't use a HeavyWeightWindow for the popup) + // note that this method does not work when SwingUtilities.getRoot() returns non-null since in that case + // this would return the application window root, not the popup root. + root = popupLabel; + while (null != root.getParent()) { + root = root.getParent(); + } + } + return root; + } + private void _setPopupSize() { // resize popup to size of label (ensure there's room for the next character so the label // doesn't show '...' in the time between when we set the text and when we increase the size Dimension labelDimension = popupLabel.getPreferredSize(); Dimension popupDimension = new Dimension(labelDimension.width + 12, labelDimension.height + 4); - SwingUtilities.getRoot(popupLabel).setSize(popupDimension); + _getPopupRoot().setSize(popupDimension); } private void _findNextMatch(int startIdx) { @@ -317,7 +332,7 @@ public enum CDeckEditorUI implements CardContainer { PopupFactory factory = PopupFactory.getSharedInstance(); Point tableLoc = tableView.getTable().getTableHeader().getLocationOnScreen(); popup = factory.getPopup(tableView.getTable(), popupLabel, tableLoc.x + 10, tableLoc.y + 10); - SwingUtilities.getRoot(popupLabel).setBackground(FSkin.getColor(FSkin.Colors.CLR_INACTIVE)); + _getPopupRoot().setBackground(FSkin.getColor(FSkin.Colors.CLR_INACTIVE)); popupTimer = new Timer(5000, new ActionListener() { @Override