Spec-Zone .ru
спецификации, руководства, описания, API
|
public class FXCanvas
extends Canvas
FXCanvas
is a component to embed JavaFX content into
SWT applications. The content to be displayed is specified
with the setScene(javafx.scene.Scene)
method that accepts an instance of
JavaFX Scene
. After the scene is assigned, it gets
repainted automatically. All the input and focus events are
forwarded to the scene transparently to the developer.
Here is a typical pattern how FXCanvas
can used:
public class Test { private static Scene createScene() { Group group = new Group(); Scene scene = new Scene(group); Button button = new Button("JFX Button"); group.getChildren().add(button); return scene; } public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); FXCanvas canvas = new FXCanvas(shell, SWT.NONE); Scene scene = createScene(); canvas.setScene(scene); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Constructor and Description |
---|
FXCanvas(Composite parent,
int style) |
Modifier and Type | Method and Description |
---|---|
Point |
computeSize(int wHint,
int hHint,
boolean changed) |
Scene |
getScene()
Returns the JavaFX scene attached to this
FXCanvas . |
void |
setScene(Scene newScene)
Attaches a
Scene object to display in this FXCanvas . |
public Point computeSize(int wHint, int hHint, boolean changed)
public Scene getScene()
FXCanvas
.Scene
attached to this FXCanvas
public void setScene(Scene newScene)
Scene
object to display in this FXCanvas
. This method must called either on the JavaFX
JavaFX application thread (which is the same as the SWT
event dispatch thread).newScene
- a scene to display in this FXCanvas
Platform.isFxApplicationThread()
Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to