JDK-8251862 : Wrong position of Popup windows at the intersection of 2 screens
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u261,9,10,openjfx11,openjfx15
  • Priority: P3
  • Status: In Progress
  • Resolution: Unresolved
  • Submitted: 2020-08-16
  • Updated: 2023-01-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx21Unresolved
Related Reports
Relates :  
Description
Build Used : jdk-8u261+8247839

When using two displays, there are wrong positions of GUI elements at the intersection of 2 screens with different scaling.

Laptop 100%
Monitor 175%

Please find the attached image showing both the screens.
_____

Please run the following sample:

import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MenuApp extends Application {

    public Parent createContent() {

        VBox vbox = new VBox(20);
        vbox.setPrefSize(300, 200);
        final MenuBar menuBar = new MenuBar();
        Menu m1 = new Menu("one");
        m1.getItems().addAll(new MenuItem("111"), new MenuItem("222"));
        Menu m2 = new Menu("two");
        m2.getItems().addAll(new MenuItem("aaa"), new MenuItem("bbb"));
        Menu menu = new Menu("menu");
        menu.getItems().addAll(m1, m2);
        menuBar.getMenus().addAll(menu);
        vbox.getChildren().addAll(menuBar);
        return vbox;
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setScene(new Scene(createContent()));
        primaryStage.show();
    }

    public static void main(String[] args) { launch(args); }
}

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/971 Date: 2022-12-07 20:12:56 +0000
07-12-2022

The bug happens when a PopupWindow is displayed on a screen other than the one the majority of the owner window is on. The most common way this can happen is when you have two screens of a different scale with the secondary screen on the left or above the primary screen. If you position the Stage such that most of it is still on the primary screen (thus the Stage is drawn using the scale of the primary screen), with a menu, a control with a context menu, or a control with a Tooltip now on the secondary screen, the popup window for the menu or Tooltip will be drawn using the screen scale of the secondary window and thus won't be positioned or sized correctly relative to the menu bar, or control in the main window. The solution is to always use the screen of the owner window, including the screen scales, when rendering a popup window. This matches the behavior of native apps, such as Notepad.
07-12-2022

I can reproduce this on JDK 9, JDK 10, and on OpenJFX 15. It happens when you drag enough of the main window onto the other screen that it changes to the scale of that screen (we get this indication from "Windows"). This is not a regression and we haven't had any reports of this issue (it's an "edge" case, both literally and figuratively). It looks like we then use that new screen scale to compute the position of the popup, but as the popup itself is displayed entirely on the old screen, the position is wrong since the screen scale used doesn't match the scale of the screen the popup is displayed on. This might be tricky to fix in all cases. When we do fix it, it will need to be fixed in the mainline first and then backported to FX 8.
17-08-2020