1 /*
2 * Copyright (c) 2013, 2016, 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
37 import java.awt.event.ContainerListener;
38 import java.awt.geom.AffineTransform;
39 import java.awt.image.BufferedImage;
40 import java.awt.image.DataBufferInt;
41 import java.beans.PropertyChangeEvent;
42 import java.beans.PropertyChangeListener;
43 import java.security.AccessController;
44 import javax.swing.JComponent;
45
46 import javax.swing.JLayeredPane;
47 import javax.swing.JPanel;
48 import javax.swing.JRootPane;
49 import javax.swing.LayoutFocusTraversalPolicy;
50 import javax.swing.RepaintManager;
51 import javax.swing.RootPaneContainer;
52 import javax.swing.SwingUtilities;
53
54 import sun.awt.AWTAccessor;
55 import sun.awt.DisplayChangedListener;
56 import sun.awt.LightweightFrame;
57 import sun.security.action.GetPropertyAction;
58 import sun.swing.SwingUtilities2.RepaintListener;
59
60 /**
61 * The frame serves as a lightweight container which paints its content
62 * to an offscreen image and provides access to the image's data via the
63 * {@link LightweightContent} interface. Note, that it may not be shown
64 * as a standalone toplevel frame. Its purpose is to provide functionality
65 * for lightweight embedding.
66 *
67 * @author Artem Ananiev
68 * @author Anton Tarasov
69 */
70 @SuppressWarnings("serial") // JDK-implementation class
71 public final class JLightweightFrame extends LightweightFrame implements RootPaneContainer {
72
73 private final JRootPane rootPane = new JRootPane();
74
75 private LightweightContent content;
76
509 * and could not be overridden.
510 */
511 private void updateClientCursor() {
512 PointerInfo pointerInfo = MouseInfo.getPointerInfo();
513 if (pointerInfo == null) {
514 /*
515 * This can happen when multiple graphics device cannot decide
516 * which graphics device contains the current mouse position
517 * or on systems without a mouse
518 */
519 return;
520 }
521 Point p = pointerInfo.getLocation();
522 SwingUtilities.convertPointFromScreen(p, this);
523 Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
524 if (target != null) {
525 content.setCursor(target.getCursor());
526 }
527 }
528
529 public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
530 Class<T> abstractRecognizerClass,
531 DragSource ds, Component c, int srcActions,
532 DragGestureListener dgl)
533 {
534 return content == null ? null : content.createDragGestureRecognizer(
535 abstractRecognizerClass, ds, c, srcActions, dgl);
536 }
537
538 public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
539 return content == null ? null : content.createDragSourceContextPeer(dge);
540 }
541
542 public void addDropTarget(DropTarget dt) {
543 if (content == null) return;
544 content.addDropTarget(dt);
545 }
546
547 public void removeDropTarget(DropTarget dt) {
548 if (content == null) return;
|
1 /*
2 * Copyright (c) 2013, 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
37 import java.awt.event.ContainerListener;
38 import java.awt.geom.AffineTransform;
39 import java.awt.image.BufferedImage;
40 import java.awt.image.DataBufferInt;
41 import java.beans.PropertyChangeEvent;
42 import java.beans.PropertyChangeListener;
43 import java.security.AccessController;
44 import javax.swing.JComponent;
45
46 import javax.swing.JLayeredPane;
47 import javax.swing.JPanel;
48 import javax.swing.JRootPane;
49 import javax.swing.LayoutFocusTraversalPolicy;
50 import javax.swing.RepaintManager;
51 import javax.swing.RootPaneContainer;
52 import javax.swing.SwingUtilities;
53
54 import sun.awt.AWTAccessor;
55 import sun.awt.DisplayChangedListener;
56 import sun.awt.LightweightFrame;
57 import sun.awt.OverrideNativeWindowHandle;
58 import sun.security.action.GetPropertyAction;
59 import sun.swing.SwingUtilities2.RepaintListener;
60
61 /**
62 * The frame serves as a lightweight container which paints its content
63 * to an offscreen image and provides access to the image's data via the
64 * {@link LightweightContent} interface. Note, that it may not be shown
65 * as a standalone toplevel frame. Its purpose is to provide functionality
66 * for lightweight embedding.
67 *
68 * @author Artem Ananiev
69 * @author Anton Tarasov
70 */
71 @SuppressWarnings("serial") // JDK-implementation class
72 public final class JLightweightFrame extends LightweightFrame implements RootPaneContainer {
73
74 private final JRootPane rootPane = new JRootPane();
75
76 private LightweightContent content;
77
510 * and could not be overridden.
511 */
512 private void updateClientCursor() {
513 PointerInfo pointerInfo = MouseInfo.getPointerInfo();
514 if (pointerInfo == null) {
515 /*
516 * This can happen when multiple graphics device cannot decide
517 * which graphics device contains the current mouse position
518 * or on systems without a mouse
519 */
520 return;
521 }
522 Point p = pointerInfo.getLocation();
523 SwingUtilities.convertPointFromScreen(p, this);
524 Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
525 if (target != null) {
526 content.setCursor(target.getCursor());
527 }
528 }
529
530 //Called by reflection by SwingNode
531 public void overrideNativeWindowHandle(long handle) {
532 final Object peer = AWTAccessor.getComponentAccessor().getPeer(this);
533 if (peer instanceof OverrideNativeWindowHandle) {
534 ((OverrideNativeWindowHandle) peer).overrideWindowHandle(handle);
535 }
536 }
537
538 public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
539 Class<T> abstractRecognizerClass,
540 DragSource ds, Component c, int srcActions,
541 DragGestureListener dgl)
542 {
543 return content == null ? null : content.createDragGestureRecognizer(
544 abstractRecognizerClass, ds, c, srcActions, dgl);
545 }
546
547 public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
548 return content == null ? null : content.createDragSourceContextPeer(dge);
549 }
550
551 public void addDropTarget(DropTarget dt) {
552 if (content == null) return;
553 content.addDropTarget(dt);
554 }
555
556 public void removeDropTarget(DropTarget dt) {
557 if (content == null) return;
|