JDK-8338378 : JFXPanel: distorted rendering when using display scale > 100%
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: jfx21
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-08-12
  • Updated: 2024-08-16
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
tbdUnresolved
Description
A DESCRIPTION OF THE PROBLEM :
When you start a JavaFX-application with an JFXPanel on a screen with scaling of 100% and you move to this window to a screen with a scaling of 125% the content of the JFXPanel looks somehow distorted, i.e. like scaled in a bad quality.

REGRESSION : Last worked in version 8u421

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the source code and move the JFX-window to screen scaled with 125%.


---------- BEGIN SOURCE ----------
package com.hexagon.applauncher.core;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.web.WebView;

public class FXWebViewInSwing {

    private JFXPanel jfxPanel ;

    public void createAndShowWindow() {
        JFrame frame = new JFrame();
        JButton quit = new JButton("Quit");
        quit.addActionListener(event -> System.exit(0));
        jfxPanel = new JFXPanel();
        Platform.runLater(this::createJFXContent);

        JPanel buttonPanel = new JPanel();
        buttonPanel.add(quit);

        frame.add(BorderLayout.CENTER, jfxPanel);
        frame.add(BorderLayout.SOUTH, buttonPanel);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(800,  800);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    private void createJFXContent() {
        WebView webView = new WebView();
        webView.getEngine().load("https://openjfx.io");
        Scene scene = new Scene(webView);
        jfxPanel.setScene(scene);
    }

    public static void main(String[] args) {
        FXWebViewInSwing swingApp = new FXWebViewInSwing();
        SwingUtilities.invokeLater(swingApp::createAndShowWindow);
    }
}

---------- END SOURCE ----------

FREQUENCY : always



Comments
I will need to test this on a dual screen setup to see whether I can reproduce it. Once I do I'll check whether this is a problem in the graphics code or in JFXPanel itself. One thing to note is that this is not a regression. The reason this scenario works in 8u421 is that HiDPI is not activated by default unless one of the screens is 150% or higher.
16-08-2024