Details
-
Bug
-
Resolution: Fixed
-
P3
-
7u55
-
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();
}
});
}
}
----
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
- duplicates
-
JDK-8087420 [JFXPanel] High JFXPanel CPU usage at high resolutions
-
- Closed
-
-
JDK-8092796 Very sluggish GUI performance when using JavaFX in a JFXPanel on late 2013 macbook pro retina
-
- Closed
-
-
JDK-8096240 JFXPanel.resizePixelBuffer slow on Mac with retina display
-
- Closed
-