-
Bug
-
Resolution: Unresolved
-
P3
-
8u40, 9, 10
-
generic
-
generic
FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64bit Professional
A DESCRIPTION OF THE PROBLEM :
Calling Node.snapshot() anywhere in the SceneGraph causes an unrelated SwingNode to resize to its preferredSize. The SwingNode in question is in a StackPane which normally stretches it to fit.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example below and press "Snapshot" button
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Layout should not change, SwingNode should be stretched to fit in StackPane
ACTUAL -
SwingNode resized to preferred size.
If the window is then manually resized it goes back to filling the window.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javafx.application.Application;
import javafx.embed.swing.SwingNode;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class NodeSnapshotLayoutBug extends Application {
@Override
public void start(Stage stage) throws Exception {
SwingNode swingNode = new SwingNode();
Button button = new Button("Snapshot");
button.setOnAction(dave -> {
button.snapshot(null, null);
});
StackPane stackPane = new StackPane(swingNode);
Scene scene = new Scene(stackPane);
stage.setScene(scene);
stage.show();
stackPane.getChildren().add(button);
SwingUtilities.invokeLater(() -> {
JPanel rigby = new JPanel();
rigby.setPreferredSize(new Dimension(300, 300));
rigby.setBackground(Color.red);
swingNode.setContent(rigby);
});
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Set a size on the Scene first
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64bit Professional
A DESCRIPTION OF THE PROBLEM :
Calling Node.snapshot() anywhere in the SceneGraph causes an unrelated SwingNode to resize to its preferredSize. The SwingNode in question is in a StackPane which normally stretches it to fit.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example below and press "Snapshot" button
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Layout should not change, SwingNode should be stretched to fit in StackPane
ACTUAL -
SwingNode resized to preferred size.
If the window is then manually resized it goes back to filling the window.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javafx.application.Application;
import javafx.embed.swing.SwingNode;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class NodeSnapshotLayoutBug extends Application {
@Override
public void start(Stage stage) throws Exception {
SwingNode swingNode = new SwingNode();
Button button = new Button("Snapshot");
button.setOnAction(dave -> {
button.snapshot(null, null);
});
StackPane stackPane = new StackPane(swingNode);
Scene scene = new Scene(stackPane);
stage.setScene(scene);
stage.show();
stackPane.getChildren().add(button);
SwingUtilities.invokeLater(() -> {
JPanel rigby = new JPanel();
rigby.setPreferredSize(new Dimension(300, 300));
rigby.setBackground(Color.red);
swingNode.setContent(rigby);
});
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Set a size on the Scene first