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

[JFXPanel, Mac Intel Iris Pro GPU] JDialog with JavaFX scene has major performance problem on Mac PowerBook w/retina display

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 7u55
    • javafx
    • Mac PowerBook w/Retina Display, 2 GHz Intel Core i7, running OSX 10.9.3

    Description

      When running this modified version of the JavaFX/Swing integration example from oracle.com on a Mac PowerBook w/retina display, major performance problems can be seen. The JavaFX scene takes 30 to 45 seconds to display when the "Open Dialog" button is pressed. There's no performance issue on my iMac, Windows 7 HP Desktop, or 17' PowerBook.

      ----

      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javafx.application.Platform;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.Scene;
      import javafx.scene.layout.StackPane;
      import javafx.scene.paint.Color;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;

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

      public class Test {

          private static void initAndShowGUI() {

           // This method is invoked on the EDT thread
              final JFrame frame = new JFrame("Swing and JavaFX");
              
              JButton dialogButton = new JButton("Open Dialog");
              
              dialogButton.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
      final JFXPanel fxPanel = new JFXPanel();

      JDialog dialog = new JDialog(frame);

      dialog.add(fxPanel);
      dialog.setSize(1024, 768);
      dialog.setLocationRelativeTo(frame);
      dialog.setVisible(true);

      Platform.runLater(new Runnable() {
      @Override
      public void run() {
      initFX(fxPanel);
      }
      });

      }
      });

              frame.add(dialogButton);
              frame.setSize(1120, 860);
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          }

          private static void initFX(JFXPanel fxPanel) {
              // This method is invoked on the JavaFX thread
              Scene scene = createScene();
              fxPanel.setScene(scene);
          }

          private static Scene createScene() {
              StackPane root = new StackPane();
              Scene scene = new Scene(root, Color.ALICEBLUE);
              Text text = new Text();
              
              text.setX(40);
              text.setY(100);
              text.setFont(new Font(25));
              text.setText("Welcome JavaFX and SWING!");

              root.getChildren().add(text);

              return (scene);
          }
          
          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      initAndShowGUI();
                  }
              });
          }
      }

      Attachments

        Issue Links

          Activity

            People

              ant Anton Tarasov (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: