ADDITIONAL SYSTEM INFORMATION :
Windows 10
OpenJDK 11, OpenJFX 11
A DESCRIPTION OF THE PROBLEM :
It appears that in JDK 11 / FX 11, the JFXPanel is not correctly handling scaled displays on Windows (i.e. where the Display Settings scale is set to something other than 100%). JavaFX is expecting the screen X & Y to already have the scaling factored in, but the Swing JFXPanel is just passing in the raw, unscaled values. This is happening for both layout positioning (e.g., combo box popups, popovers, etc.) and mouse event handling (e.g., tooltips, custom mouse handlers, etc.)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a machine with multiple monitors, go to Windows Settings -> Display and configure each display to have a scaling value greater than 100% (e.g., 125%, 150%, 200%, etc.)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using a JFXPanel to embed JavaFX controls in a Swing component should position all items such as combo box pop-ups, context menus, tooltips, etc. in the correct location, thus properly accounting for the display scaling.
ACTUAL -
FX nodes such as combo box pop-ups, context menus, tooltips, etc. are displayed offset from their correct location.
---------- BEGIN SOURCE ----------
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Spinner;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.VBox;
import javax.swing.JFrame;
public class JFXPanelExample extends JFrame
{
public JFXPanelExample()
{
super("JFXPanel Example");
JFXPanel jfxPanel = new JFXPanel();
ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().setAll("Option A", "Option B", "Option C");
comboBox.setTooltip(new Tooltip("Select an option"));
Spinner<Integer> spinner = new Spinner<>(0, 100, 50);
spinner.setTooltip(new Tooltip("Spinner range: [0, 100]"));
VBox vBox = new VBox(comboBox, spinner);
vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(10.0);
Platform.runLater(() -> jfxPanel.setScene(new Scene(vBox)));
this.add(jfxPanel);
pack();
}
public static void main(String[] args)
{
JFXPanelExample window = new JFXPanelExample();
window.setSize(300, 200);
window.setLocation(200, 200);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 10
OpenJDK 11, OpenJFX 11
A DESCRIPTION OF THE PROBLEM :
It appears that in JDK 11 / FX 11, the JFXPanel is not correctly handling scaled displays on Windows (i.e. where the Display Settings scale is set to something other than 100%). JavaFX is expecting the screen X & Y to already have the scaling factored in, but the Swing JFXPanel is just passing in the raw, unscaled values. This is happening for both layout positioning (e.g., combo box popups, popovers, etc.) and mouse event handling (e.g., tooltips, custom mouse handlers, etc.)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a machine with multiple monitors, go to Windows Settings -> Display and configure each display to have a scaling value greater than 100% (e.g., 125%, 150%, 200%, etc.)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using a JFXPanel to embed JavaFX controls in a Swing component should position all items such as combo box pop-ups, context menus, tooltips, etc. in the correct location, thus properly accounting for the display scaling.
ACTUAL -
FX nodes such as combo box pop-ups, context menus, tooltips, etc. are displayed offset from their correct location.
---------- BEGIN SOURCE ----------
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Spinner;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.VBox;
import javax.swing.JFrame;
public class JFXPanelExample extends JFrame
{
public JFXPanelExample()
{
super("JFXPanel Example");
JFXPanel jfxPanel = new JFXPanel();
ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().setAll("Option A", "Option B", "Option C");
comboBox.setTooltip(new Tooltip("Select an option"));
Spinner<Integer> spinner = new Spinner<>(0, 100, 50);
spinner.setTooltip(new Tooltip("Spinner range: [0, 100]"));
VBox vBox = new VBox(comboBox, spinner);
vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(10.0);
Platform.runLater(() -> jfxPanel.setScene(new Scene(vBox)));
this.add(jfxPanel);
pack();
}
public static void main(String[] args)
{
JFXPanelExample window = new JFXPanelExample();
window.setSize(300, 200);
window.setLocation(200, 200);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8222210 JFXPanel popups open at wrong coordinates when using multiple hidpi monitors
-
- Resolved
-