FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The Swing content of a SwingNode does not update properly after being resized, when direct 3D is disabled (Java system property -Dsun.java2d.d3d=false). We need this property to work around other bugs.
The provided test case is a slight modification of the example in the javadoc of SwingNode, these changes were applied:
- it does not use a JButton, but uses a JPanel
- it disables direct 3D using sun.java2d.d3d=false
If either of those modifications is reverted, resizing does work.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Start the attached sample
- Resize the window
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Swing content of the SwingNode resizes and repaints when the JavaFX node is resized
ACTUAL -
The Swing content does not resize, or even turns completely black or grey.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class SwingFX extends Application {
@Override
public void start(Stage stage) {
final SwingNode swingNode = new SwingNode();
createAndSetSwingContent(swingNode);
StackPane pane = new StackPane();
pane.getChildren().add(swingNode);
stage.setScene(new Scene(pane, 100, 50));
stage.show();
}
private void createAndSetSwingContent(final SwingNode swingNode) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JPanel panel = new JPanel();
panel.setBackground(java.awt.Color.BLUE);
panel.setBorder(BorderFactory.createLineBorder(Color.CYAN, 5));
swingNode.setContent(panel);
// Using the original content from the Javadoc example does work for some reason.
// swingNode.setContent(new JButton("Click me!"));
}
});
}
public static void main(String[] args) {
// When this property is set to true (the default), resizing the window does resize the Swing content.
System.setProperty("sun.java2d.d3d", "false");
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Move the window (by dragging the title bar). The content is now refreshed properly.
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The Swing content of a SwingNode does not update properly after being resized, when direct 3D is disabled (Java system property -Dsun.java2d.d3d=false). We need this property to work around other bugs.
The provided test case is a slight modification of the example in the javadoc of SwingNode, these changes were applied:
- it does not use a JButton, but uses a JPanel
- it disables direct 3D using sun.java2d.d3d=false
If either of those modifications is reverted, resizing does work.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Start the attached sample
- Resize the window
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Swing content of the SwingNode resizes and repaints when the JavaFX node is resized
ACTUAL -
The Swing content does not resize, or even turns completely black or grey.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class SwingFX extends Application {
@Override
public void start(Stage stage) {
final SwingNode swingNode = new SwingNode();
createAndSetSwingContent(swingNode);
StackPane pane = new StackPane();
pane.getChildren().add(swingNode);
stage.setScene(new Scene(pane, 100, 50));
stage.show();
}
private void createAndSetSwingContent(final SwingNode swingNode) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JPanel panel = new JPanel();
panel.setBackground(java.awt.Color.BLUE);
panel.setBorder(BorderFactory.createLineBorder(Color.CYAN, 5));
swingNode.setContent(panel);
// Using the original content from the Javadoc example does work for some reason.
// swingNode.setContent(new JButton("Click me!"));
}
});
}
public static void main(String[] args) {
// When this property is set to true (the default), resizing the window does resize the Swing content.
System.setProperty("sun.java2d.d3d", "false");
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Move the window (by dragging the title bar). The content is now refreshed properly.
- duplicates
-
JDK-8154846 SwingNode does not resize when content size constraints are changed
-
- Resolved
-
- relates to
-
JDK-8297829 With direct 3D (D3D) ToolTips triggers extra high GPU usage
-
- Closed
-