use of javafx.embed.swing.SwingNode in project TeachingInSimulation by ScOrPiOzzy.
the class WordViewerTest method start.
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.initStyle(StageStyle.TRANSPARENT);
SWTPanel swt = new SWTPanel();
swt.setSize(1366, 768);
JPanel panel = new JPanel();
panel.setSize(1366, 768);
panel.add(swt);
SwingNode node = new SwingNode();
node.setContent(panel);
StackPane root = new StackPane(node);
Scene scene = new Scene(root);
scene.setFill(null);
primaryStage.setScene(scene);
primaryStage.setWidth(1366);
primaryStage.setHeight(768);
primaryStage.show();
}
use of javafx.embed.swing.SwingNode in project dwoss by gg-net.
the class FxCore method wrap.
public static SwingNode wrap(final JPanel p) throws ExecutionException, InterruptedException, InvocationTargetException {
return SwingSaft.dispatch(() -> {
SwingNode swingNode = new SwingNode();
swingNode.setContent(p);
return swingNode;
});
}
use of javafx.embed.swing.SwingNode in project dwoss by gg-net.
the class BuilderUtil method wrapJPanel.
/**
* Call from EventQueue: Wraps the expected uiparameter.jpanel in the expected pane with a swingnode as children.
* Also updates the global parent mapping and the prefered size of the pane
*
* @param in the uiparamter
* @return the uiparamter
*/
static UiParameter wrapJPanel(UiParameter in) {
Objects.requireNonNull(in.getPane(), "Pane in UiParameter is null");
Objects.requireNonNull(in.getJPanel(), "JPanel in UiParameter is null");
if (in.getPane().getChildren().isEmpty())
throw new IllegalStateException("Supplied Pane has no children, but a SwingNode is expected");
SwingNode sn = in.getPane().getChildren().stream().filter(n -> n instanceof SwingNode).map(n -> (SwingNode) n).findAny().orElseThrow(() -> new IllegalStateException("No Node of the supplied Pane is of type SwingNode"));
sn.setContent(in.getJPanel());
StaticParentMapperJavaFx.map(in.getJPanel(), sn);
Dimension preferredSize = in.getJPanel().getPreferredSize();
L.debug("Setting Swing Size to JavaFx {}", preferredSize);
in.getPane().setPrefHeight(preferredSize.getHeight());
in.getPane().setPrefWidth(preferredSize.getWidth());
return in;
}
Aggregations