jdk/src/share/classes/sun/swing/JLightweightFrame.java
author anthony
Tue, 12 Aug 2014 14:22:05 +0400
changeset 26342 3637212ae8f2
parent 25195 9de77f5b0df2
permissions -rw-r--r--
8049065: [JLightweightFrame] Support DnD for SwingNode Summary: Delegate DnD operations to LightweightContent when appropriate Reviewed-by: ant, pchelko
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     1
/*
22618
927e4fe6cb24 8033221: Fix serial lint warnings in sun.swing.*
darcy
parents: 20136
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     4
 *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    10
 *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    15
 * accompanied this code).
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    16
 *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    20
 *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    23
 * questions.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    24
 */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    25
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    26
package sun.swing;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    27
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    28
import java.awt.BorderLayout;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    29
import java.awt.Color;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    30
import java.awt.Component;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    31
import java.awt.Container;
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
    32
import java.awt.Dimension;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    33
import java.awt.EventQueue;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    34
import java.awt.Graphics;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    35
import java.awt.Graphics2D;
20127
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
    36
import java.awt.MouseInfo;
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
    37
import java.awt.Point;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    38
import java.awt.Rectangle;
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
    39
import java.awt.Window;
26342
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    40
import java.awt.dnd.DragGestureEvent;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    41
import java.awt.dnd.DragGestureListener;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    42
import java.awt.dnd.DragGestureRecognizer;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    43
import java.awt.dnd.DragSource;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    44
import java.awt.dnd.DropTarget;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    45
import java.awt.dnd.InvalidDnDOperationException;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    46
import java.awt.dnd.peer.DragSourceContextPeer;
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
    47
import java.awt.event.ContainerEvent;
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
    48
import java.awt.event.ContainerListener;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    49
import java.awt.image.BufferedImage;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    50
import java.awt.image.DataBufferInt;
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
    51
import java.beans.PropertyChangeEvent;
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
    52
import java.beans.PropertyChangeListener;
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    53
import java.security.AccessController;
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
    54
import javax.swing.JComponent;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    55
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    56
import javax.swing.JLayeredPane;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    57
import javax.swing.JPanel;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    58
import javax.swing.JRootPane;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    59
import javax.swing.LayoutFocusTraversalPolicy;
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
    60
import javax.swing.RepaintManager;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    61
import javax.swing.RootPaneContainer;
20127
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
    62
import javax.swing.SwingUtilities;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    63
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
    64
import sun.awt.DisplayChangedListener;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    65
import sun.awt.LightweightFrame;
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    66
import sun.security.action.GetPropertyAction;
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
    67
import sun.swing.SwingUtilities2.RepaintListener;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    68
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    69
/**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    70
 * The frame serves as a lightweight container which paints its content
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    71
 * to an offscreen image and provides access to the image's data via the
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    72
 * {@link LightweightContent} interface. Note, that it may not be shown
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    73
 * as a standalone toplevel frame. Its purpose is to provide functionality
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    74
 * for lightweight embedding.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    75
 *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    76
 * @author Artem Ananiev
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    77
 * @author Anton Tarasov
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    78
 */
22618
927e4fe6cb24 8033221: Fix serial lint warnings in sun.swing.*
darcy
parents: 20136
diff changeset
    79
@SuppressWarnings("serial") // JDK-implementation class
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    80
public final class JLightweightFrame extends LightweightFrame implements RootPaneContainer {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    81
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    82
    private final JRootPane rootPane = new JRootPane();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    83
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    84
    private LightweightContent content;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    85
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    86
    private Component component;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    87
    private JPanel contentPane;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    88
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    89
    private BufferedImage bbImage;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    90
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
    91
    private volatile int scaleFactor = 1;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
    92
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    93
    /**
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    94
     * {@code copyBufferEnabled}, true by default, defines the following strategy.
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    95
     * A duplicating (copy) buffer is created for the original pixel buffer.
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    96
     * The copy buffer is synchronized with the original buffer every time the
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    97
     * latter changes. {@code JLightweightFrame} passes the copy buffer array
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    98
     * to the {@link LightweightContent#imageBufferReset} method. The code spot
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
    99
     * which synchronizes two buffers becomes the only critical section guarded
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   100
     * by the lock (managed with the {@link LightweightContent#paintLock()},
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   101
     * {@link LightweightContent#paintUnlock()} methods).
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   102
     */
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   103
    private static boolean copyBufferEnabled;
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   104
    private int[] copyBuffer;
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   105
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   106
    private PropertyChangeListener layoutSizeListener;
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   107
    private RepaintListener repaintListener;
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   108
20127
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   109
    static {
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   110
        SwingAccessor.setJLightweightFrameAccessor(new SwingAccessor.JLightweightFrameAccessor() {
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   111
            @Override
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   112
            public void updateCursor(JLightweightFrame frame) {
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   113
                frame.updateClientCursor();
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   114
            }
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   115
        });
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   116
        copyBufferEnabled = "true".equals(AccessController.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   117
            doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));
20127
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   118
    }
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   119
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   120
    /**
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   121
     * Constructs a new, initially invisible {@code JLightweightFrame}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   122
     * instance.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   123
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   124
    public JLightweightFrame() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   125
        super();
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   126
        copyBufferEnabled = "true".equals(AccessController.
20136
594c0830f18c 8022512: JLightweightFrame: the content pane should be transparent
ant
parents: 20127
diff changeset
   127
            doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   128
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   129
        add(rootPane, BorderLayout.CENTER);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   130
        setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
16706
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   131
        if (getGraphicsConfiguration().isTranslucencyCapable()) {
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   132
            setBackground(new Color(0, 0, 0, 0));
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   133
        }
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   134
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   135
        layoutSizeListener = new PropertyChangeListener() {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   136
            @Override
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   137
            public void propertyChange(PropertyChangeEvent e) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   138
                Dimension d = (Dimension)e.getNewValue();
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   139
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   140
                if ("preferredSize".equals(e.getPropertyName())) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   141
                    content.preferredSizeChanged(d.width, d.height);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   142
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   143
                } else if ("maximumSize".equals(e.getPropertyName())) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   144
                    content.maximumSizeChanged(d.width, d.height);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   145
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   146
                } else if ("minimumSize".equals(e.getPropertyName())) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   147
                    content.minimumSizeChanged(d.width, d.height);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   148
                }
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   149
            }
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   150
        };
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   151
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   152
        repaintListener = (JComponent c, int x, int y, int w, int h) -> {
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   153
            Window jlf = SwingUtilities.getWindowAncestor(c);
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   154
            if (jlf != JLightweightFrame.this) {
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   155
                return;
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   156
            }
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   157
            Point p = SwingUtilities.convertPoint(c, x, y, jlf);
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   158
            Rectangle r = new Rectangle(p.x, p.y, w, h).intersection(
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   159
                    new Rectangle(0, 0, bbImage.getWidth() / scaleFactor,
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   160
                                  bbImage.getHeight() / scaleFactor));
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   161
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   162
            if (!r.isEmpty()) {
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   163
                notifyImageUpdated(r.x, r.y, r.width, r.height);
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   164
            }
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   165
        };
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   166
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   167
        SwingAccessor.getRepaintManagerAccessor().addRepaintListener(
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   168
            RepaintManager.currentManager(this), repaintListener);
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   169
    }
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   170
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   171
    @Override
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   172
    public void dispose() {
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   173
        SwingAccessor.getRepaintManagerAccessor().removeRepaintListener(
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   174
            RepaintManager.currentManager(this), repaintListener);
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   175
        super.dispose();
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   176
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   177
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   178
    /**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   179
     * Sets the {@link LightweightContent} instance for this frame.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   180
     * The {@code JComponent} object returned by the
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   181
     * {@link LightweightContent#getComponent()} method is immediately
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   182
     * added to the frame's content pane.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   183
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   184
     * @param content the {@link LightweightContent} instance
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   185
     */
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   186
    public void setContent(final LightweightContent content) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   187
        if (content == null) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   188
            System.err.println("JLightweightFrame.setContent: content may not be null!");
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   189
            return;
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   190
        }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   191
        this.content = content;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   192
        this.component = content.getComponent();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   193
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   194
        Dimension d = this.component.getPreferredSize();
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   195
        content.preferredSizeChanged(d.width, d.height);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   196
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   197
        d = this.component.getMaximumSize();
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   198
        content.maximumSizeChanged(d.width, d.height);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   199
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   200
        d = this.component.getMinimumSize();
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   201
        content.minimumSizeChanged(d.width, d.height);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   202
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   203
        initInterior();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   204
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   205
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   206
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   207
    public Graphics getGraphics() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   208
        if (bbImage == null) return null;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   209
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   210
        Graphics2D g = bbImage.createGraphics();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   211
        g.setBackground(getBackground());
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   212
        g.setColor(getForeground());
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   213
        g.setFont(getFont());
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   214
        g.scale(scaleFactor, scaleFactor);
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   215
        return g;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   216
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   217
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   218
    /**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   219
     * {@inheritDoc}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   220
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   221
     * @see LightweightContent#focusGrabbed()
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   222
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   223
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   224
    public void grabFocus() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   225
        if (content != null) content.focusGrabbed();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   226
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   227
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   228
    /**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   229
     * {@inheritDoc}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   230
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   231
     * @see LightweightContent#focusUngrabbed()
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   232
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   233
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   234
    public void ungrabFocus() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   235
        if (content != null) content.focusUngrabbed();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   236
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   237
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   238
    @Override
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   239
    public int getScaleFactor() {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   240
        return scaleFactor;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   241
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   242
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   243
    @Override
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   244
    public void notifyDisplayChanged(final int scaleFactor) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   245
        if (scaleFactor != this.scaleFactor) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   246
            if (!copyBufferEnabled) content.paintLock();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   247
            try {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   248
                if (bbImage != null) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   249
                    resizeBuffer(getWidth(), getHeight(), scaleFactor);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   250
                }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   251
            } finally {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   252
                if (!copyBufferEnabled) content.paintUnlock();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   253
            }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   254
            this.scaleFactor = scaleFactor;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   255
        }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   256
        if (getPeer() instanceof DisplayChangedListener) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   257
            ((DisplayChangedListener)getPeer()).displayChanged();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   258
        }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   259
        repaint();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   260
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   261
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   262
    @Override
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   263
    public void addNotify() {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   264
        super.addNotify();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   265
        if (getPeer() instanceof DisplayChangedListener) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   266
            ((DisplayChangedListener)getPeer()).displayChanged();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   267
        }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   268
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   269
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   270
    private void syncCopyBuffer(boolean reset, int x, int y, int w, int h, int scale) {
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   271
        content.paintLock();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   272
        try {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   273
            int[] srcBuffer = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   274
            if (reset) {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   275
                copyBuffer = new int[srcBuffer.length];
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   276
            }
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   277
            int linestride = bbImage.getWidth();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   278
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   279
            x *= scale;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   280
            y *= scale;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   281
            w *= scale;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   282
            h *= scale;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   283
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   284
            for (int i=0; i<h; i++) {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   285
                int from = (y + i) * linestride + x;
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   286
                System.arraycopy(srcBuffer, from, copyBuffer, from, w);
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   287
            }
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   288
        } finally {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   289
            content.paintUnlock();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   290
        }
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   291
    }
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   292
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   293
    private void notifyImageUpdated(int x, int y, int width, int height) {
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   294
        if (copyBufferEnabled) {
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   295
            syncCopyBuffer(false, x, y, width, height, scaleFactor);
23280
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   296
        }
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   297
        content.imageUpdated(x, y, width, height);
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   298
    }
df31f522531f 8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents: 20136
diff changeset
   299
22618
927e4fe6cb24 8033221: Fix serial lint warnings in sun.swing.*
darcy
parents: 20136
diff changeset
   300
    @SuppressWarnings("serial") // anonymous class inside
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   301
    private void initInterior() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   302
        contentPane = new JPanel() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   303
            @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   304
            public void paint(Graphics g) {
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   305
                if (!copyBufferEnabled) {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   306
                    content.paintLock();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   307
                }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   308
                try {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   309
                    super.paint(g);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   310
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   311
                    final Rectangle clip = g.getClipBounds() != null ?
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   312
                            g.getClipBounds() :
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   313
                            new Rectangle(0, 0, contentPane.getWidth(), contentPane.getHeight());
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   314
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   315
                    clip.x = Math.max(0, clip.x);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   316
                    clip.y = Math.max(0, clip.y);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   317
                    clip.width = Math.min(contentPane.getWidth(), clip.width);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   318
                    clip.height = Math.min(contentPane.getHeight(), clip.height);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   319
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   320
                    EventQueue.invokeLater(new Runnable() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   321
                        @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   322
                        public void run() {
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   323
                            Rectangle c = contentPane.getBounds().intersection(clip);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   324
                            notifyImageUpdated(c.x, c.y, c.width, c.height);
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   325
                        }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   326
                    });
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   327
                } finally {
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   328
                    if (!copyBufferEnabled) {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   329
                        content.paintUnlock();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   330
                    }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   331
                }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   332
            }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   333
            @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   334
            protected boolean isPaintingOrigin() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   335
                return true;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   336
            }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   337
        };
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   338
        contentPane.setLayout(new BorderLayout());
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   339
        contentPane.add(component);
20136
594c0830f18c 8022512: JLightweightFrame: the content pane should be transparent
ant
parents: 20127
diff changeset
   340
        if ("true".equals(AccessController.
594c0830f18c 8022512: JLightweightFrame: the content pane should be transparent
ant
parents: 20127
diff changeset
   341
            doPrivileged(new GetPropertyAction("swing.jlf.contentPaneTransparent", "false"))))
594c0830f18c 8022512: JLightweightFrame: the content pane should be transparent
ant
parents: 20127
diff changeset
   342
        {
594c0830f18c 8022512: JLightweightFrame: the content pane should be transparent
ant
parents: 20127
diff changeset
   343
            contentPane.setOpaque(false);
594c0830f18c 8022512: JLightweightFrame: the content pane should be transparent
ant
parents: 20127
diff changeset
   344
        }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   345
        setContentPane(contentPane);
19026
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   346
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   347
        contentPane.addContainerListener(new ContainerListener() {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   348
            @Override
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   349
            public void componentAdded(ContainerEvent e) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   350
                Component c = JLightweightFrame.this.component;
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   351
                if (e.getChild() == c) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   352
                    c.addPropertyChangeListener("preferredSize", layoutSizeListener);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   353
                    c.addPropertyChangeListener("maximumSize", layoutSizeListener);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   354
                    c.addPropertyChangeListener("minimumSize", layoutSizeListener);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   355
                }
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   356
            }
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   357
            @Override
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   358
            public void componentRemoved(ContainerEvent e) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   359
                Component c = JLightweightFrame.this.component;
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   360
                if (e.getChild() == c) {
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   361
                    c.removePropertyChangeListener(layoutSizeListener);
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   362
                }
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   363
            }
96141cb8d7eb 8020927: JLightweightFrame API should export layout properties change notifications
ant
parents: 17415
diff changeset
   364
        });
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   365
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   366
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   367
    @SuppressWarnings("deprecation")
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   368
    @Override public void reshape(int x, int y, int width, int height) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   369
        super.reshape(x, y, width, height);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   370
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   371
        if (width == 0 || height == 0) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   372
            return;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   373
        }
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   374
        if (!copyBufferEnabled) {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   375
            content.paintLock();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   376
        }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   377
        try {
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   378
            boolean createBB = (bbImage == null);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   379
            int newW = width;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   380
            int newH = height;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   381
            if (bbImage != null) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   382
                int imgWidth = bbImage.getWidth() / scaleFactor;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   383
                int imgHeight = bbImage.getHeight() / scaleFactor;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   384
                if (width != imgWidth || height != imgHeight) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   385
                    createBB = true;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   386
                    if (bbImage != null) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   387
                        int oldW = imgWidth;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   388
                        int oldH = imgHeight;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   389
                        if ((oldW >= newW) && (oldH >= newH)) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   390
                            createBB = false;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   391
                        } else {
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   392
                            if (oldW >= newW) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   393
                                newW = oldW;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   394
                            } else {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   395
                                newW = Math.max((int)(oldW * 1.2), width);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   396
                            }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   397
                            if (oldH >= newH) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   398
                                newH = oldH;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   399
                            } else {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   400
                                newH = Math.max((int)(oldH * 1.2), height);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   401
                            }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   402
                        }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   403
                    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   404
                }
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   405
            }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   406
            if (createBB) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   407
                resizeBuffer(newW, newH, scaleFactor);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   408
                return;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   409
            }
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   410
            content.imageReshaped(0, 0, width, height);
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   411
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   412
        } finally {
17415
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   413
            if (!copyBufferEnabled) {
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   414
                content.paintUnlock();
62b97a10da72 8014227: JLightweightFrame needs another synchronization policy
ant
parents: 16706
diff changeset
   415
            }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   416
        }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   417
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   418
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   419
    private void resizeBuffer(int width, int height, int newScaleFactor) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   420
            bbImage = new BufferedImage(width*newScaleFactor,height*newScaleFactor,
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   421
                                        BufferedImage.TYPE_INT_ARGB_PRE);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   422
        int[] pixels= ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   423
        if (copyBufferEnabled) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   424
            syncCopyBuffer(true, 0, 0, width, height, newScaleFactor);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   425
            pixels = copyBuffer;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   426
        }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   427
        content.imageBufferReset(pixels, 0, 0, width, height,
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   428
                                 width * newScaleFactor, newScaleFactor);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   429
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 23281
diff changeset
   430
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   431
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   432
    public JRootPane getRootPane() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   433
        return rootPane;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   434
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   435
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   436
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   437
    public void setContentPane(Container contentPane) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   438
        getRootPane().setContentPane(contentPane);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   439
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   440
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   441
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   442
    public Container getContentPane() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   443
        return getRootPane().getContentPane();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   444
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   445
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   446
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   447
    public void setLayeredPane(JLayeredPane layeredPane) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   448
        getRootPane().setLayeredPane(layeredPane);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   449
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   450
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   451
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   452
    public JLayeredPane getLayeredPane() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   453
        return getRootPane().getLayeredPane();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   454
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   455
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   456
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   457
    public void setGlassPane(Component glassPane) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   458
        getRootPane().setGlassPane(glassPane);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   459
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   460
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   461
    @Override
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   462
    public Component getGlassPane() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   463
        return getRootPane().getGlassPane();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   464
    }
20127
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   465
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   466
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   467
    /*
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   468
     * Notifies client toolkit that it should change a cursor.
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   469
     *
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   470
     * Called from the peer via SwingAccessor, because the
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   471
     * Component.updateCursorImmediately method is final
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   472
     * and could not be overridden.
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   473
     */
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   474
    private void updateClientCursor() {
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   475
        Point p = MouseInfo.getPointerInfo().getLocation();
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   476
        SwingUtilities.convertPointFromScreen(p, this);
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   477
        Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   478
        if (target != null) {
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   479
            content.setCursor(target.getCursor());
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   480
        }
a3a34675d847 8024170: [SwingNode] Implement cursor change
pchelko
parents: 19026
diff changeset
   481
    }
26342
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   482
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   483
    public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   484
            Class<T> abstractRecognizerClass,
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   485
            DragSource ds, Component c, int srcActions,
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   486
            DragGestureListener dgl)
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   487
    {
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   488
        return content == null ? null : content.createDragGestureRecognizer(
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   489
                abstractRecognizerClass, ds, c, srcActions, dgl);
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   490
    }
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   491
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   492
    public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   493
        return content == null ? null : content.createDragSourceContextPeer(dge);
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   494
    }
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   495
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   496
    public void addDropTarget(DropTarget dt) {
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   497
        if (content == null) return;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   498
        content.addDropTarget(dt);
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   499
    }
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   500
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   501
    public void removeDropTarget(DropTarget dt) {
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   502
        if (content == null) return;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   503
        content.removeDropTarget(dt);
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   504
    }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   505
}