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

JFXPanel does not work in fullscreen mode



      We would like to use some pieces of JavaFX in our existing Swing application. Porting everything to JavaFX is not an option right now. The application is fullscreen which seems to cause the Swing integration to fail. I've created a small sample that reproduces the problem.

      I have a simple JFXPanel with a WebView (tried to replace it with a Button and the result is the same) in a JFrame. As long as the JFrame is not set in fullscreen mode everything works fine, but when I add the following code the area were the JFXPanel is remains grey.

              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice gs = ge.getDefaultScreenDevice();

      For completness I am adding the entire code that I used to reproduce the problem.

      import javafx.application.Application;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      import javax.swing.JFrame;
      import javax.swing.SwingUtilities;
      import java.awt.BorderLayout;
      import java.awt.Dimension;
      import java.awt.GraphicsDevice;
      import java.awt.GraphicsEnvironment;

      public class MainTest extends Application {

          private static JFXPanel javafxPanel;

          private void initAndShowFrame() {
              JFrame frame = new JFrame("JxBrowser");

              javafxPanel = new JFXPanel();
              javafxPanel.setPreferredSize(new Dimension(1024,800));

              frame.getContentPane().add(javafxPanel, BorderLayout.CENTER);

              // Create JavaFX scene.
              Application.launch(MainTest.class, null);

              frame.setSize(new Dimension(1024, 800));

              // if these following 3 lines are commented out, everything works fine.
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice gs = ge.getDefaultScreenDevice();

          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      MainTest jxBrowser = new MainTest();

          public void start(final Stage stage) throws Exception {
              //Create the scene and the stage

              Group root = new Group();
              final Scene scene = new Scene(root);
              final WebEngine webEngine = new WebEngine();
              WebView webView = new WebView(webEngine);

              // Add scene to panel



          Issue Links



              • Assignee:
                art Artem Ananiev
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                3 Start watching this issue


                • Created: