Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8338378

JFXPanel: distorted rendering when using display scale > 100%

XMLWordPrintable

    • generic
    • generic

      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


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: