diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ae2a8f..44682445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ FlatLaf Change Log `StringBuilder`, `StringBuffer`, or any other object that returns HTML text in method `toString()`. (similar to issue #12) - ComboBox: Fixed popup border painting on HiDPI screens (e.g. at 150% scaling). +- ComboBox: Fixed popup location if shown above of combo box (Java 8 only). - ComboBox (editable): Fixed wrong border of internal text field under special circumstances. - Spinner: Fixed painting of border corners on left side. (issue #382; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java index 9517405b..392efd52 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java @@ -730,6 +730,21 @@ public class FlatComboBoxUI return height; } + @Override + public void show( Component invoker, int x, int y ) { + // Java 8: fix y coordinate if popup is shown above the combobox + // (already fixed in Java 9+ https://bugs.openjdk.java.net/browse/JDK-7072653) + if( y < 0 && !SystemInfo.isJava_9_orLater ) { + Border popupBorder = getBorder(); + if( popupBorder != null ) { + Insets insets = popupBorder.getBorderInsets( this ); + y -= insets.top + insets.bottom; + } + } + + super.show( invoker, x, y ); + } + @Override protected void paintChildren( Graphics g ) { super.paintChildren( g );