8202199: Provide public, unsupported JDK API for JavaFX/Swing interop
Reviewed-by: prr, kcr, alanb, mchung
--- a/src/java.desktop/share/classes/module-info.java Wed Jun 13 12:54:41 2018 +0100
+++ b/src/java.desktop/share/classes/module-info.java Fri Jun 15 23:38:59 2018 +0530
@@ -108,7 +108,12 @@
// qualified exports may be inserted at build time
// see make/GensrcModuleInfo.gmk
exports sun.awt to
- jdk.accessibility;
+ jdk.accessibility,
+ jdk.unsupported.desktop;
+
+ exports java.awt.dnd.peer to jdk.unsupported.desktop;
+ exports sun.awt.dnd to jdk.unsupported.desktop;
+ exports sun.swing to jdk.unsupported.desktop;
opens javax.swing.plaf.basic to
jdk.jconsole;
@@ -131,6 +136,8 @@
uses javax.sound.sampled.spi.FormatConversionProvider;
uses javax.sound.sampled.spi.MixerProvider;
+ uses sun.swing.InteropProvider;
+
provides sun.datatransfer.DesktopDatatransferService with
sun.awt.datatransfer.DesktopDatatransferServiceImpl;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/share/classes/sun/swing/InteropProvider.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.swing;
+
+public interface InteropProvider {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/DispatcherWrapper.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop;
+
+import java.awt.SecondaryLoop;
+import java.awt.EventQueue;
+import sun.awt.FwDispatcher;
+import sun.awt.AWTAccessor;
+
+/**
+ * This class provides a wrapper over inner class DispatcherProxy
+ * which implements jdk internal sun.awt.FwDispatcher interface
+ * and provides APIs to be used by FX swing interop to access and use
+ * FwDispatcher APIs.
+ *
+ * @since 11
+ */
+public abstract class DispatcherWrapper {
+ private DispatcherProxy fwd;
+
+ public DispatcherWrapper() {
+ fwd = new DispatcherProxy();
+ }
+
+ public abstract boolean isDispatchThread();
+
+ public abstract void scheduleDispatch(Runnable r);
+
+ public abstract SecondaryLoop createSecondaryLoop();
+
+ public static void setFwDispatcher(EventQueue eventQueue, DispatcherWrapper dispatcher) {
+ AWTAccessor.getEventQueueAccessor().setFwDispatcher(eventQueue, dispatcher.fwd);
+ }
+
+ private class DispatcherProxy implements FwDispatcher {
+
+ @Override
+ public boolean isDispatchThread() {
+ return DispatcherWrapper.this.isDispatchThread();
+ }
+
+ @Override
+ public void scheduleDispatch(Runnable r) {
+ DispatcherWrapper.this.scheduleDispatch(r);
+ }
+
+ @Override
+ public SecondaryLoop createSecondaryLoop() {
+ return DispatcherWrapper.this.createSecondaryLoop();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/DragSourceContextWrapper.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop;
+
+import java.awt.Cursor;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
+import java.util.Map;
+import sun.awt.dnd.SunDragSourceContextPeer;
+
+/**
+ * This class provides a wrapper over inner DragSourceContextPeerProxy class
+ * which extends jdk internal sun.awt.dnd.SunDragSourceContextPeer class
+ * and provides APIs to be used by FX swing interop to access and use
+ * DragSourceContextPeer APIs.
+ *
+ * @since 11
+ */
+public abstract class DragSourceContextWrapper {
+ private DragSourceContextPeerProxy dsp;
+
+ public DragSourceContextWrapper(DragGestureEvent e) {
+ dsp = new DragSourceContextPeerProxy(e);
+ }
+
+ DragSourceContextPeer getPeer() {
+ return dsp;
+ }
+
+ public static int convertModifiersToDropAction(int modifiers,
+ int supportedActions) {
+ return DragSourceContextPeerProxy.
+ convertModifiersToDropAction(modifiers, supportedActions);
+ }
+
+ protected abstract void setNativeCursor(Cursor c, int cType);
+
+ protected abstract void startDrag(Transferable trans, long[] formats,
+ Map<Long, DataFlavor> formatMap);
+
+ public abstract void startSecondaryEventLoop();
+
+ public abstract void quitSecondaryEventLoop();
+
+ public void dragDropFinished(final boolean success,
+ final int operations,
+ final int x, final int y) {
+ dsp.dragDropFinishedCall(success, operations, x, y);
+ }
+
+ public DragSourceContext getDragSourceContext() {
+ return dsp.getDragSourceContextCall();
+ }
+
+ private class DragSourceContextPeerProxy extends SunDragSourceContextPeer {
+
+ public DragSourceContextPeerProxy(DragGestureEvent e) {
+ super(e);
+ }
+
+ protected void startDrag(Transferable trans, long[] formats,
+ Map<Long, DataFlavor> formatMap) {
+ DragSourceContextWrapper.this.startDrag(trans, formats, formatMap);
+ }
+
+ protected void setNativeCursor(long nativeCtxt, Cursor c, int cType) {
+ DragSourceContextWrapper.this.setNativeCursor(c, cType);
+ }
+
+ public void startSecondaryEventLoop() {
+ DragSourceContextWrapper.this.startSecondaryEventLoop();
+ }
+
+ public void quitSecondaryEventLoop() {
+ DragSourceContextWrapper.this.quitSecondaryEventLoop();
+ }
+
+ protected void dragDropFinishedCall(final boolean success,
+ final int operations,
+ final int x, final int y) {
+ dragDropFinished(success, operations, x, y);
+ }
+
+ protected DragSourceContext getDragSourceContextCall() {
+ return getDragSourceContext();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/DropTargetContextWrapper.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop;
+
+import java.awt.dnd.peer.DropTargetContextPeer;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.DropTargetContext;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import sun.awt.AWTAccessor;
+
+/**
+ * This class provides a wrapper over inner class DropTargetContextPeerProxy
+ * which implements jdk internal java.awt.dnd.peer.DropTargetContextPeer interface
+ * and provides APIs to be used by FX swing interop to access and use
+ * DropTargetContextPeer APIs.
+ *
+ * @since 11
+ */
+public abstract class DropTargetContextWrapper {
+
+ private DropTargetContextPeerProxy dcp;
+ public DropTargetContextWrapper() {
+ dcp = new DropTargetContextPeerProxy();
+ }
+
+ public void setDropTargetContext(DropTargetContext dtc,
+ DropTargetContextWrapper dtcpw) {
+ AWTAccessor.getDropTargetContextAccessor().
+ setDropTargetContextPeer(dtc, dtcpw.dcp);
+ }
+
+ public void reset(DropTargetContext dtc) {
+ AWTAccessor.getDropTargetContextAccessor().reset(dtc);
+ }
+
+ public abstract void setTargetActions(int actions);
+
+ public abstract int getTargetActions();
+
+ public abstract DropTarget getDropTarget();
+
+ public abstract DataFlavor[] getTransferDataFlavors();
+
+ public abstract Transferable getTransferable() throws InvalidDnDOperationException;
+
+ public abstract boolean isTransferableJVMLocal();
+
+ public abstract void acceptDrag(int dragAction);
+
+ public abstract void rejectDrag();
+
+ public abstract void acceptDrop(int dropAction);
+
+ public abstract void rejectDrop();
+
+ public abstract void dropComplete(boolean success);
+
+ private class DropTargetContextPeerProxy implements DropTargetContextPeer {
+
+ public void setTargetActions(int actions) {
+ DropTargetContextWrapper.this.setTargetActions(actions);
+ }
+
+ public int getTargetActions() {
+ return DropTargetContextWrapper.this.getTargetActions();
+ }
+
+ public DropTarget getDropTarget() {
+ return DropTargetContextWrapper.this.getDropTarget();
+ }
+
+ public DataFlavor[] getTransferDataFlavors() {
+ return DropTargetContextWrapper.this.getTransferDataFlavors();
+ }
+
+ public Transferable getTransferable()
+ throws InvalidDnDOperationException {
+ return DropTargetContextWrapper.this.getTransferable();
+ }
+
+ public boolean isTransferableJVMLocal() {
+ return DropTargetContextWrapper.this.isTransferableJVMLocal();
+ }
+
+ public void acceptDrag(int dragAction) {
+ DropTargetContextWrapper.this.acceptDrag(dragAction);
+ }
+
+ public void rejectDrag() {
+ DropTargetContextWrapper.this.rejectDrag();
+ }
+
+ public void acceptDrop(int dropAction) {
+ DropTargetContextWrapper.this.acceptDrop(dropAction);
+ }
+
+ public void rejectDrop() {
+ DropTargetContextWrapper.this.rejectDrop();
+ }
+
+ public void dropComplete(boolean success) {
+ DropTargetContextWrapper.this.dropComplete(success);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/LightweightContentWrapper.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop;
+
+import java.awt.Component;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.dnd.DropTarget;
+import javax.swing.JComponent;
+import sun.swing.LightweightContent;
+
+/**
+ * This class provides a wrapper over inner LightweightContentProxy class
+ * which implements jdk internal sun.swing.LightweightContent interface
+ * and provides APIs to be used by FX swing interop to access and use
+ * LightweightContent APIs.
+ *
+ * @since 11
+ */
+public abstract class LightweightContentWrapper {
+ private LightweightContentProxy lwCnt;
+
+ public LightweightContentWrapper() {
+ lwCnt = new LightweightContentProxy();
+ }
+
+ LightweightContentProxy getContent() {
+ return lwCnt;
+ }
+
+ public abstract void imageBufferReset(int[] data, int x, int y, int width,
+ int height, int linestride);
+
+ public abstract void imageBufferReset(int[] data, int x, int y, int width,
+ int height,
+ int linestride, double scaleX,
+ double scaleY);
+
+ public abstract JComponent getComponent();
+
+ public abstract void paintLock();
+
+ public abstract void paintUnlock();
+
+ public abstract void imageReshaped(int x, int y, int width, int height);
+
+ public abstract void imageUpdated(int dirtyX, int dirtyY,int dirtyWidth,
+ int dirtyHeight);
+
+ public abstract void focusGrabbed();
+
+ public abstract void focusUngrabbed();
+
+ public abstract void preferredSizeChanged(int width, int height);
+
+ public abstract void maximumSizeChanged(int width, int height);
+
+ public abstract void minimumSizeChanged(int width, int height);
+
+ public abstract <T extends DragGestureRecognizer> T createDragGestureRecognizer(
+ Class<T> abstractRecognizerClass,
+ DragSource ds, Component c, int srcActions,
+ DragGestureListener dgl);
+
+ public abstract DragSourceContextWrapper createDragSourceContext(DragGestureEvent dge)
+ throws InvalidDnDOperationException;
+
+ public abstract void addDropTarget(DropTarget dt);
+
+ public abstract void removeDropTarget(DropTarget dt);
+
+ private class LightweightContentProxy implements LightweightContent {
+
+ public JComponent getComponent() {
+ return LightweightContentWrapper.this.getComponent();
+ }
+
+ public void paintLock() {
+ LightweightContentWrapper.this.paintLock();
+ }
+
+ public void paintUnlock() {
+ LightweightContentWrapper.this.paintUnlock();
+ }
+
+ public void imageBufferReset(int[] data, int x, int y, int width,
+ int height, int linestride) {
+ LightweightContentWrapper.this.imageBufferReset(data, x, y, width,
+ height, linestride);
+ }
+
+ public void imageBufferReset(int[] data, int x, int y, int width,
+ int height, int linestride, double scaleX,
+ double scaleY) {
+ LightweightContentWrapper.this.imageBufferReset(data, x, y, width,
+ height, linestride, scaleX, scaleY);
+ }
+
+ public void imageReshaped(int x, int y, int width, int height) {
+ LightweightContentWrapper.this.imageReshaped(x, y, width, height);
+ }
+
+ public void imageUpdated(int dirtyX, int dirtyY,int dirtyWidth, int dirtyHeight) {
+ LightweightContentWrapper.this.imageUpdated(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
+ }
+
+ public void focusGrabbed() {
+ LightweightContentWrapper.this.focusGrabbed();
+ }
+
+ public void focusUngrabbed() {
+ LightweightContentWrapper.this.focusUngrabbed();
+ }
+
+ public void preferredSizeChanged(int width, int height) {
+ LightweightContentWrapper.this.preferredSizeChanged(width, height);
+ }
+
+ public void maximumSizeChanged(int width, int height) {
+ LightweightContentWrapper.this.maximumSizeChanged(width, height);
+ }
+
+ public void minimumSizeChanged(int width, int height) {
+ LightweightContentWrapper.this.minimumSizeChanged(width, height);
+ }
+
+ public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
+ Class<T> abstractRecognizerClass,
+ DragSource ds, Component c, int srcActions,
+ DragGestureListener dgl) {
+ return LightweightContentWrapper.this.createDragGestureRecognizer(
+ abstractRecognizerClass, ds, c, srcActions, dgl);
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
+ throws InvalidDnDOperationException {
+ DragSourceContextWrapper peerWrapper =
+ LightweightContentWrapper.this.createDragSourceContext(dge);
+ return peerWrapper.getPeer();
+ }
+
+ public void addDropTarget(DropTarget dt) {
+ LightweightContentWrapper.this.addDropTarget(dt);
+ }
+
+ public void removeDropTarget(DropTarget dt) {
+ LightweightContentWrapper.this.removeDropTarget(dt);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/LightweightFrameWrapper.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop;
+
+import java.awt.AWTEvent;
+import java.awt.Container;
+import java.awt.Component;
+import java.awt.event.WindowFocusListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.KeyEvent;
+import sun.awt.LightweightFrame;
+import sun.awt.UngrabEvent;
+import sun.awt.AWTAccessor;
+import sun.swing.JLightweightFrame;
+
+/**
+ * This class wraps sun.swing.JLightweightFrame and implements
+ * APIs to be used by FX swing interop to access and use JLightweightFrame APIs.
+ *
+ * @since 11
+ */
+public class LightweightFrameWrapper {
+
+ JLightweightFrame lwFrame;
+
+ public LightweightFrameWrapper() {
+ lwFrame = new JLightweightFrame();
+ }
+
+ private JLightweightFrame getLightweightFrame() {
+ return lwFrame;
+ }
+
+ public void notifyDisplayChanged(final int scaleFactor) {
+ if (lwFrame != null) {
+ lwFrame.notifyDisplayChanged(scaleFactor, scaleFactor);
+ }
+ }
+
+ /**
+ * {@code overrideNativeWindowHandle()} is package private but
+ * part of the interface of this class. It supports providing a
+ * foreign native window handle (i.e. an FX window handle) to AWT,
+ * and as such is intended to be called via JNI code,
+ * not by Java code, so it is not public.
+ */
+ void overrideNativeWindowHandle(long handle, Runnable closeWindow) {
+ if (lwFrame != null) {
+ lwFrame.overrideNativeWindowHandle(handle, closeWindow);
+ }
+ }
+
+ public void setHostBounds(int x, int y, int w, int h) {
+ if (lwFrame != null) {
+ lwFrame.setHostBounds(x, y, w, h);
+ }
+ }
+
+ public void dispose() {
+ if (lwFrame != null) {
+ lwFrame.dispose();
+ }
+ }
+
+ public void addWindowFocusListener(WindowFocusListener listener) {
+ if (lwFrame != null) {
+ lwFrame.addWindowFocusListener(listener);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if (lwFrame != null) {
+ lwFrame.setVisible(visible);
+ }
+ }
+
+ public void setBounds(int x, int y, int w, int h) {
+ if (lwFrame != null) {
+ lwFrame.setBounds(x, y, w, h);
+ }
+ }
+
+ public void setContent(final LightweightContentWrapper lwCntWrapper) {
+ if (lwFrame != null) {
+ lwFrame.setContent(lwCntWrapper.getContent());
+ }
+ }
+
+ public void emulateActivation(boolean activate) {
+ if (lwFrame != null) {
+ lwFrame.emulateActivation(activate);
+ }
+ }
+
+ public MouseEvent createMouseEvent(LightweightFrameWrapper lwFrame,
+ int swingID, long swingWhen, int swingModifiers,
+ int relX, int relY, int absX, int absY,
+ int clickCount, boolean swingPopupTrigger,
+ int swingButton) {
+ return new java.awt.event.MouseEvent(lwFrame.getLightweightFrame(),
+ swingID, swingWhen,
+ swingModifiers,
+ relX, relY, absX, absY, clickCount,
+ swingPopupTrigger, swingButton);
+ }
+
+ public MouseWheelEvent createMouseWheelEvent(LightweightFrameWrapper lwFrame,
+ int swingModifiers, int x, int y, int wheelRotation) {
+ return new MouseWheelEvent(lwFrame.getLightweightFrame(),
+ java.awt.event.MouseEvent.MOUSE_WHEEL,
+ System.currentTimeMillis(),
+ swingModifiers, x, y, 0, 0, 0, false,
+ MouseWheelEvent.WHEEL_UNIT_SCROLL, 1,
+ wheelRotation);
+ }
+
+ public KeyEvent createKeyEvent(LightweightFrameWrapper lwFrame,
+ int swingID, long swingWhen,
+ int swingModifiers,
+ int swingKeyCode, char swingChar) {
+ return new java.awt.event.KeyEvent(lwFrame.getLightweightFrame(),
+ swingID, swingWhen, swingModifiers, swingKeyCode,
+ swingChar);
+ }
+
+ public AWTEvent createUngrabEvent(LightweightFrameWrapper lwFrame) {
+ return new UngrabEvent(lwFrame.getLightweightFrame());
+ }
+
+ public Component findComponentAt(LightweightFrameWrapper cont, int x, int y, boolean ignoreEnabled) {
+ Container lwframe = cont.getLightweightFrame();
+ return AWTAccessor.getContainerAccessor().findComponentAt(lwframe, x, y, ignoreEnabled);
+ }
+
+ public boolean isCompEqual(Component c, LightweightFrameWrapper lwFrame) {
+ return c != lwFrame.getLightweightFrame();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/SwingInterOpUtils.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop;
+
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.AWTEvent;
+import sun.awt.SunToolkit;
+import sun.awt.AppContext;
+import sun.awt.UngrabEvent;
+
+/**
+ * This class provides static utility methods to be used by FX swing interop
+ * to access and use jdk internal classes like SunToolkit, AppContext
+ * and UngrabEvent.
+ *
+ * @since 11
+ */
+public class SwingInterOpUtils {
+
+ public static void postEvent(Object target, java.awt.AWTEvent e) {
+ AppContext context = SunToolkit.targetToAppContext(target);
+ if (context != null) {
+ SunToolkit.postEvent(context, e);
+ }
+ }
+
+ public static void grab(Toolkit toolkit, Window window) {
+ if (toolkit instanceof SunToolkit) {
+ ((SunToolkit)toolkit).grab(window);
+ }
+ }
+
+ public static void ungrab(Toolkit toolkit, Window window) {
+ if (toolkit instanceof SunToolkit) {
+ ((SunToolkit)toolkit).ungrab(window);
+ }
+ }
+
+ public static boolean isUngrabEvent(AWTEvent e) {
+ return e instanceof UngrabEvent;
+ }
+
+ public static final int GRAB_EVENT_MASK = SunToolkit.GRAB_EVENT_MASK;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/internal/InteropProviderImpl.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.swing.interop.internal;
+
+import sun.swing.InteropProvider;
+
+/**
+ * @since 11
+ */
+public class InteropProviderImpl implements InteropProvider {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/module-info.java Fri Jun 15 23:38:59 2018 +0530
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/**
+ * This module is intended for use only by the javafx.swing module
+ * for the purpose of FX/Swing interop
+ *
+ * @since 11
+ */
+module jdk.unsupported.desktop {
+
+ requires transitive java.desktop;
+
+ exports jdk.swing.interop;
+
+ provides sun.swing.InteropProvider
+ with jdk.swing.interop.internal.InteropProviderImpl;
+
+}
+