-
Bug
-
Resolution: Unresolved
-
P4
-
jfx14
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Windows 10
JDK 11.0.6
JavaFX 14.0.1
A DESCRIPTION OF THE PROBLEM :
Use the following class to display a chart. Click anywhere in the chart. On JDK 8 or on mac, the popup menu appears where the mouse is. On JDK 11 on Windows 10 with the display set to 125% scaling in the Windows settings and with -Dsun.java2d.uiScale=1.0 as a JVM argument, the popup menu appears to the right and down from the mouse, displaced by 25% from where it should be, presumably due to incorrect scaling of the position.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this application below on Windows 10 using Windows scaling set to 125% with JDK 11.0.6 and JavaFX 14.0.1, and use the JVM argument -Dsun.java2d.uiScale=1.0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On mouse click, popup menu should appear where the mouse is
ACTUAL -
On mouse click, popup menu appears down and right of the mouse position
---------- BEGIN SOURCE ----------
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseEvent;
import javax.swing.JFrame;
public class ContextMenuShowBug {
public static void main(String[] args) {
JFrame frame = new JFrame();
JFXPanel panel = new JFXPanel();
frame.add(panel);
frame.setSize(1000, 1000);
frame.setVisible(true);
Platform.runLater(new Runnable() {
@Override
public void run() {
XYChart chart = new AreaChart(new NumberAxis(), new NumberAxis());
Scene myScene = new Scene(chart, 1000, 1000);
panel.setScene(myScene);
ContextMenu myContextMenu = new ContextMenu(new MenuItem("Menu"));
EventHandler<MouseEvent> myEventHandler =
e -> myContextMenu.show(chart, e.getScreenX(), e.getScreenY());
myScene.addEventHandler(MouseEvent.MOUSE_CLICKED, myEventHandler);
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Reverse the scaling given by e.getScreenX and e.getScreenY by the scaling used by Windows (e.g. 25%).
Windows 10
JDK 11.0.6
JavaFX 14.0.1
A DESCRIPTION OF THE PROBLEM :
Use the following class to display a chart. Click anywhere in the chart. On JDK 8 or on mac, the popup menu appears where the mouse is. On JDK 11 on Windows 10 with the display set to 125% scaling in the Windows settings and with -Dsun.java2d.uiScale=1.0 as a JVM argument, the popup menu appears to the right and down from the mouse, displaced by 25% from where it should be, presumably due to incorrect scaling of the position.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this application below on Windows 10 using Windows scaling set to 125% with JDK 11.0.6 and JavaFX 14.0.1, and use the JVM argument -Dsun.java2d.uiScale=1.0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On mouse click, popup menu should appear where the mouse is
ACTUAL -
On mouse click, popup menu appears down and right of the mouse position
---------- BEGIN SOURCE ----------
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseEvent;
import javax.swing.JFrame;
public class ContextMenuShowBug {
public static void main(String[] args) {
JFrame frame = new JFrame();
JFXPanel panel = new JFXPanel();
frame.add(panel);
frame.setSize(1000, 1000);
frame.setVisible(true);
Platform.runLater(new Runnable() {
@Override
public void run() {
XYChart chart = new AreaChart(new NumberAxis(), new NumberAxis());
Scene myScene = new Scene(chart, 1000, 1000);
panel.setScene(myScene);
ContextMenu myContextMenu = new ContextMenu(new MenuItem("Menu"));
EventHandler<MouseEvent> myEventHandler =
e -> myContextMenu.show(chart, e.getScreenX(), e.getScreenY());
myScene.addEventHandler(MouseEvent.MOUSE_CLICKED, myEventHandler);
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Reverse the scaling given by e.getScreenX and e.getScreenY by the scaling used by Windows (e.g. 25%).