javafx.embed.swt

## Class FXCanvas

- java.lang.Object
- - org.eclipse.swt.widgets.Widget
  - - org.eclipse.swt.widgets.Control
    - - org.eclipse.swt.widgets.Scrollable
      - - org.eclipse.swt.widgets.Composite
        - - org.eclipse.swt.widgets.Canvas
          - - javafx.embed.swt.FXCanvas

- All Implemented Interfaces:
    org.eclipse.swt.graphics.Drawable

      public class FXCanvas
      extends org.eclipse.swt.widgets.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();
              }
          }

  Since:
    JavaFX 2.0

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.swt.widgets.Composite

      `embeddedHandle`

    - ### Fields inherited from class org.eclipse.swt.widgets.Widget

      `handle`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FXCanvas(org.eclipse.swt.widgets.Composite parent, int style)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.eclipse.swt.graphics.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`.

    - ### Methods inherited from class org.eclipse.swt.widgets.Canvas

      `drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME`

    - ### Methods inherited from class org.eclipse.swt.widgets.Composite

      `changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList`

    - ### Methods inherited from class org.eclipse.swt.widgets.Scrollable

      `computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar`

    - ### Methods inherited from class org.eclipse.swt.widgets.Control

      `addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update`

    - ### Methods inherited from class org.eclipse.swt.widgets.Widget

      `addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FXCanvas

          public FXCanvas(org.eclipse.swt.widgets.Composite parent,
                          int style)

  - ### Method Detail

    - #### computeSize

          public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                            int hHint,
                                                            boolean changed)

      Overrides:
        `computeSize` in class `org.eclipse.swt.widgets.Composite`

    - #### getScene

          public Scene getScene()

      Returns the JavaFX scene attached to this `FXCanvas`.
      Returns:
        the `Scene` attached to this `FXCanvas`

    - #### setScene

          public void setScene(Scene newScene)

      Attaches a `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).
      Parameters:
        `newScene` - a scene to display in this `FXCanvas`
      See Also:
        `Platform.isFxApplicationThread()`

Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.