1 /*
2 * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
64 import javax.swing.JComponent;
65 import javax.swing.SwingUtilities;
66
67 import com.sun.javafx.application.PlatformImpl;
68 import com.sun.javafx.cursor.CursorFrame;
69 import com.sun.javafx.embed.AbstractEvents;
70 import com.sun.javafx.embed.EmbeddedSceneInterface;
71 import com.sun.javafx.embed.EmbeddedStageInterface;
72 import com.sun.javafx.embed.HostInterface;
73 import com.sun.javafx.stage.EmbeddedWindow;
74 import com.sun.javafx.tk.Toolkit;
75 import com.sun.javafx.PlatformUtil;
76 import java.awt.event.InvocationEvent;
77
78 import java.lang.reflect.Method;
79 import java.util.concurrent.atomic.AtomicInteger;
80 import sun.awt.AppContext;
81 import sun.awt.SunToolkit;
82 import sun.java2d.SunGraphics2D;
83 import sun.java2d.SurfaceData;
84 import sun.util.logging.PlatformLogger;
85 import sun.util.logging.PlatformLogger.Level;
86
87 /**
88 * {@code JFXPanel} is a component to embed JavaFX content into
89 * Swing applications. The content to be displayed is specified
90 * with the {@link #setScene} method that accepts an instance of
91 * JavaFX {@code Scene}. After the scene is assigned, it gets
92 * repainted automatically. All the input and focus events are
93 * forwarded to the scene transparently to the developer.
94 * <p>
95 * There are some restrictions related to {@code JFXPanel}. As a
96 * Swing component, it should only be accessed from the event
97 * dispatch thread, except the {@link #setScene} method, which can
98 * be called either on the event dispatch thread or on the JavaFX
99 * application thread.
100 * <p>
101 * Here is a typical pattern how {@code JFXPanel} can used:
102 * <pre>
103 * public class Test {
104 *
105 * private static void initAndShowGUI() {
|
1 /*
2 * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
64 import javax.swing.JComponent;
65 import javax.swing.SwingUtilities;
66
67 import com.sun.javafx.application.PlatformImpl;
68 import com.sun.javafx.cursor.CursorFrame;
69 import com.sun.javafx.embed.AbstractEvents;
70 import com.sun.javafx.embed.EmbeddedSceneInterface;
71 import com.sun.javafx.embed.EmbeddedStageInterface;
72 import com.sun.javafx.embed.HostInterface;
73 import com.sun.javafx.stage.EmbeddedWindow;
74 import com.sun.javafx.tk.Toolkit;
75 import com.sun.javafx.PlatformUtil;
76 import java.awt.event.InvocationEvent;
77
78 import java.lang.reflect.Method;
79 import java.util.concurrent.atomic.AtomicInteger;
80 import sun.awt.AppContext;
81 import sun.awt.SunToolkit;
82 import sun.java2d.SunGraphics2D;
83 import sun.java2d.SurfaceData;
84 import com.sun.javafx.logging.PlatformLogger;
85 import com.sun.javafx.logging.PlatformLogger.Level;
86
87 /**
88 * {@code JFXPanel} is a component to embed JavaFX content into
89 * Swing applications. The content to be displayed is specified
90 * with the {@link #setScene} method that accepts an instance of
91 * JavaFX {@code Scene}. After the scene is assigned, it gets
92 * repainted automatically. All the input and focus events are
93 * forwarded to the scene transparently to the developer.
94 * <p>
95 * There are some restrictions related to {@code JFXPanel}. As a
96 * Swing component, it should only be accessed from the event
97 * dispatch thread, except the {@link #setScene} method, which can
98 * be called either on the event dispatch thread or on the JavaFX
99 * application thread.
100 * <p>
101 * Here is a typical pattern how {@code JFXPanel} can used:
102 * <pre>
103 * public class Test {
104 *
105 * private static void initAndShowGUI() {
|