setContent method
that accepts an instance of Swing JComponent. The hierarchy of components
contained in the JComponent instance should not contain any heavyweight
components, otherwise SwingNode may fail to paint it. The content gets
repainted automatically. All the input and focus events are forwarded to the
JComponent instance transparently to the developer.
Here is a typical pattern which demonstrates how SwingNode can be used:
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() {
swingNode.setContent(new JButton("Click me!"));
}
});
}
public static void main(String[] args) {
launch(args);
}
}
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private static class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private volatile JComponent | |
| private Timer | |
| private WeakReference | |
| private double | |
| private double | |
| private boolean | |
| private Window | |
| private static boolean | |
| private final InvalidationListener | |
| private volatile Object | |
| private final ReentrantLock | |
| private NGExternalNode | peer
Hides javafx. |
| private List | |
| private DisposerRecord | |
| private final ChangeListener | |
| private boolean | |
| private int | |
| private int | |
| private int | |
| private int | |
| private int | |
| private int | |
| private SwingNodeInteropN | |
| private final EventHandler | |
| private EventHandler | |
| private final ChangeListener |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| private void | |
| private void | |
| private boolean | |
| private BaseBounds | |
| private NGNode | |
| private void | |
| public JComponent | Returns: the Swing component attached to thisSwingNodeReturns the |
| private final Object | |
| private ReentrantLock | |
| public boolean | isResizable()
Overrides javafx. Indicates whether this node is a type which can be resized by its parent. |
| private void | |
| public double | Returns: the maximum height that the node should be resized to during layoutthe width that should be used if maximum height depends on it width)Overrides javafx. Returns the |
| public double | Returns: the maximum width that the node should be resized to during layoutthe height that should be used if maximum width depends on it height)Overrides javafx. Returns the |
| public double | Returns: the minimum height that the node should be resized to during layoutthe width that should be used if minimum height depends on it width)Overrides javafx. Returns the |
| public double | Returns: the minimum width that the node should be resized to during layoutthe height that should be used if minimum width depends on it height)Overrides javafx. Returns the |
| private void | |
| private static void | |
| public double | Returns: the preferred height that the node should be resized to during layoutthe width that should be used if preferred height depends on it width)Overrides javafx. Returns the |
| public double | Returns: the preferred width that the node should be resized to during layoutthe height that should be used if preferred width depends on it height)Overrides javafx. Returns the |
| private void | |
| private void | |
| pack-priv void | |
| public void | resize(final double
the target layout bounds width width, final double the target layout bounds height height)Overrides javafx. Invoked by the |
| public void | setContent(final JComponent
a Swing component to display in this content)SwingNodeAttaches a |
| private void | |
| pack-priv void | |
| pack-priv void | setImageBuffer(final int[] data, final int x, final int y, final int w, final int h, final int linestride, final double scaleX, final double scaleY)
|
| private void | |
| private void | |
| private void |
| content | back to summary |
|---|---|
| private volatile JComponent content | |
| deactivate | back to summary |
|---|---|
| private Timer deactivate | |
| disposerRecRef | back to summary |
|---|---|
| private WeakReference<T> disposerRecRef | |
| fxHeight | back to summary |
|---|---|
| private double fxHeight | |
| fxWidth | back to summary |
|---|---|
| private double fxWidth | |
| grabbed | back to summary |
|---|---|
| private boolean grabbed | |
| hWindow | back to summary |
|---|---|
| private Window hWindow | |
| isThreadMerged | back to summary |
|---|---|
| private static boolean isThreadMerged | |
| locationListener | back to summary |
|---|---|
| private final InvalidationListener locationListener | |
| lwFrame | back to summary |
|---|---|
| private volatile Object lwFrame | |
| paintLock | back to summary |
|---|---|
| private final ReentrantLock paintLock | |
| peer | back to summary |
|---|---|
| private NGExternalNode peer Hides javafx. | |
| peerRequests | back to summary |
|---|---|
| private List<Runnable> peerRequests | |
| rec | back to summary |
|---|---|
| private DisposerRecord rec | |
| sceneWindowListener | back to summary |
|---|---|
| private final ChangeListener<Window> sceneWindowListener | |
| skipBackwardUnrgabNotification | back to summary |
|---|---|
| private boolean skipBackwardUnrgabNotification | |
| swingMaxHeight | back to summary |
|---|---|
| private int swingMaxHeight | |
| swingMaxWidth | back to summary |
|---|---|
| private int swingMaxWidth | |
| swingMinHeight | back to summary |
|---|---|
| private int swingMinHeight | |
| swingMinWidth | back to summary |
|---|---|
| private int swingMinWidth | |
| swingPrefHeight | back to summary |
|---|---|
| private int swingPrefHeight | |
| swingPrefWidth | back to summary |
|---|---|
| private int swingPrefWidth | |
| swNodeIOP | back to summary |
|---|---|
| private SwingNodeInteropN swNodeIOP | |
| ungrabHandler | back to summary |
|---|---|
| private final EventHandler<FocusUngrabEvent> ungrabHandler | |
| windowHiddenHandler | back to summary |
|---|---|
| private EventHandler<T extends Event> windowHiddenHandler | |
| windowVisibleListener | back to summary |
|---|---|
| private final ChangeListener<Boolean> windowVisibleListener | |
| SwingNode | back to summary |
|---|---|
| public SwingNode() Constructs a new instance of | |
| activateLwFrame | back to summary |
|---|---|
| private void activateLwFrame(final boolean activate) | |
| addSceneListeners | back to summary |
|---|---|
| private void addSceneListeners(final Scene scene) | |
| addWindowListeners | back to summary |
|---|---|
| private void addWindowListeners(final Window window) | |
| disposeLwFrame | back to summary |
|---|---|
| private void disposeLwFrame() | |
| doComputeContains | back to summary |
|---|---|
| private boolean doComputeContains(double localX, double localY) | |
| doComputeGeomBounds | back to summary |
|---|---|
| private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx) | |
| doCreatePeer | back to summary |
|---|---|
| private NGNode doCreatePeer() | |
| doUpdatePeer | back to summary |
|---|---|
| private void doUpdatePeer() | |
| getContent | back to summary |
|---|---|
| public JComponent getContent() Returns the The method can be called either on the JavaFX Application thread or the Event Dispatch thread. Note however, that access to a Swing component must occur from the Event Dispatch thread according to the Swing threading restrictions.
| |
| getLightweightFrame | back to summary |
|---|---|
| private final Object getLightweightFrame() | |
| getPaintLock | back to summary |
|---|---|
| private ReentrantLock getPaintLock() | |
| isResizable | back to summary |
|---|---|
| public boolean isResizable() Overrides javafx. Doc from javafx. Indicates whether this node is a type which can be resized by its parent. If this method returns true, then the parent will resize the node (ideally within its size range) by calling node.resize(width,height) during the layout pass. All Regions, Controls, and WebView are resizable classes which depend on their parents resizing them during layout once all sizing and CSS styling information has been applied. If this method returns false, then the parent cannot resize it during layout (resize() is a no-op) and it should return its layoutBounds for minimum, preferred, and maximum sizes. Group, Text, and all Shapes are not resizable and hence depend on the application to establish their sizing by setting appropriate properties (e.g. width/height for Rectangle, text on Text, and so on). Non-resizable nodes may still be relocated during layout.
| |
| locateLwFrame | back to summary |
|---|---|
| private void locateLwFrame() | |
| maxHeight | back to summary |
|---|---|
| public double maxHeight(double width) Overrides javafx. Returns the
| |
| maxWidth | back to summary |
|---|---|
| public double maxWidth(double height) Overrides javafx. Returns the
| |
| minHeight | back to summary |
|---|---|
| public double minHeight(double width) Overrides javafx. Returns the
| |
| minWidth | back to summary |
|---|---|
| public double minWidth(double height) Overrides javafx. Returns the
| |
| notifyNativeHandle | back to summary |
|---|---|
| private void notifyNativeHandle(Window window) | |
| postAWTEvent | back to summary |
|---|---|
| private static void postAWTEvent(AWTEvent event) | |
| prefHeight | back to summary |
|---|---|
| public double prefHeight(double width) Overrides javafx. Returns the
| |
| prefWidth | back to summary |
|---|---|
| public double prefWidth(double height) Overrides javafx. Returns the
| |
| removeSceneListeners | back to summary |
|---|---|
| private void removeSceneListeners(Scene scene) | |
| removeWindowListeners | back to summary |
|---|---|
| private void removeWindowListeners(final Window window) | |
| repaintDirtyRegion | back to summary |
|---|---|
| pack-priv void repaintDirtyRegion(final int dirtyX, final int dirtyY, final int dirtyWidth, final int dirtyHeight) | |
| resize | back to summary |
|---|---|
| public void resize(final double width, final double height) Overrides javafx. Invoked by the
| |
| setContent | back to summary |
|---|---|
| public void setContent(final JComponent content) Attaches a The method can be called either on the JavaFX Application thread or the Event Dispatch thread. Note however, that access to a Swing component must occur from the Event Dispatch thread according to the Swing threading restrictions.
| |
| setContentImpl | back to summary |
|---|---|
| private void setContentImpl(JComponent content) | |
| setImageBounds | back to summary |
|---|---|
| pack-priv void setImageBounds(final int x, final int y, final int w, final int h) | |
| setImageBuffer | back to summary |
|---|---|
| pack-priv void setImageBuffer(final int[] data, final int x, final int y, final int w, final int h, final int linestride, final double scaleX, final double scaleY) | |
| setLwFrameScale | back to summary |
|---|---|
| private void setLwFrameScale(final double scaleX, final double scaleY) | |
| setLwFrameVisible | back to summary |
|---|---|
| private void setLwFrameVisible(final boolean visible) | |
| ungrabFocus | back to summary |
|---|---|
| private void ungrabFocus(boolean postUngrabEvent) | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | handle(KeyEvent
the event which occurred event)Implements javafx. Invoked when a specific event of the type for which this handler is registered happens. |
| SwingKeyEventHandler | back to summary |
|---|---|
| private SwingKeyEventHandler() | |
| handle | back to summary |
|---|---|
| public void handle(KeyEvent event) Implements javafx. Doc from javafx. Invoked when a specific event of the type for which this handler is registered happens. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Set |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | handle(MouseEvent
the event which occurred event)Implements javafx. Invoked when a specific event of the type for which this handler is registered happens. |
| mouseClickedAllowed | back to summary |
|---|---|
| private final Set<MouseButton> mouseClickedAllowed | |
| SwingMouseEventHandler | back to summary |
|---|---|
| private SwingMouseEventHandler() | |
| handle | back to summary |
|---|---|
| public void handle(MouseEvent event) Implements javafx. Doc from javafx. Invoked when a specific event of the type for which this handler is registered happens.
| |
| Modifier and Type | Field and Description |
|---|---|
| private WeakReference |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | windowGainedFocus(WindowEvent
the event to be processed e)Implements java. Invoked when the Window is set to be the focused Window, which means that the Window, or one of its subcomponents, will receive keyboard events. |
| public void | windowLostFocus(WindowEvent
the event to be processed e)Implements java. Invoked when the Window is no longer the focused Window, which means that keyboard events will no longer be delivered to the Window or any of its subcomponents. |
| swingNodeRef | back to summary |
|---|---|
| private WeakReference<SwingNode> swingNodeRef | |
| SwingNodeWindowFocusListener | back to summary |
|---|---|
| pack-priv SwingNodeWindowFocusListener(SwingNode swingNode) | |
| windowGainedFocus | back to summary |
|---|---|
| public void windowGainedFocus(WindowEvent e) Implements java. Doc from java. Invoked when the Window is set to be the focused Window, which means that the Window, or one of its subcomponents, will receive keyboard events.
| |
| windowLostFocus | back to summary |
|---|---|
| public void windowLostFocus(WindowEvent e) Implements java. Doc from java. Invoked when the Window is no longer the focused Window, which means that keyboard events will no longer be delivered to the Window or any of its subcomponents.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | handle(ScrollEvent
the event which occurred event)Implements javafx. Invoked when a specific event of the type for which this handler is registered happens. |
| private void |
| SwingScrollEventHandler | back to summary |
|---|---|
| private SwingScrollEventHandler() | |
| handle | back to summary |
|---|---|
| public void handle(ScrollEvent event) Implements javafx. Doc from javafx. Invoked when a specific event of the type for which this handler is registered happens.
| |
| sendMouseWheelEvent | back to summary |
|---|---|
| private void sendMouseWheelEvent(Object source, double fxX, double fxY, int swingModifiers, double delta) | |