jdk/src/java.desktop/share/classes/sun/awt/LightweightFrame.java
author darcy
Mon, 15 Dec 2014 17:20:17 -0800
changeset 28231 b608ffcaed74
parent 26353 b5e3b7fbf56d
child 30469 bac0a7ff7e1e
permissions -rw-r--r--
8066621: Suppress deprecation warnings in java.desktop module Reviewed-by: prr, alanb, ptbrunet
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
/*
28231
b608ffcaed74 8066621: Suppress deprecation warnings in java.desktop module
darcy
parents: 26353
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.awt;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    27
26342
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    28
import java.awt.Component;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    29
import java.awt.Container;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    30
import java.awt.Frame;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    31
import java.awt.Graphics;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    32
import java.awt.Image;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    33
import java.awt.MenuBar;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    34
import java.awt.MenuComponent;
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
    35
import java.awt.Rectangle;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    36
import java.awt.Toolkit;
26342
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    37
import java.awt.dnd.DragGestureEvent;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    38
import java.awt.dnd.DragGestureListener;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    39
import java.awt.dnd.DragGestureRecognizer;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    40
import java.awt.dnd.DragSource;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    41
import java.awt.dnd.DropTarget;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    42
import java.awt.dnd.InvalidDnDOperationException;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
    43
import java.awt.dnd.peer.DragSourceContextPeer;
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    44
import java.awt.peer.FramePeer;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    45
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    46
/**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    47
 * The class provides basic functionality for a lightweight frame
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    48
 * implementation. A subclass is expected to provide painting to an
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    49
 * offscreen image and access to it. Thus it can be used for lightweight
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    50
 * embedding.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    51
 *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    52
 * @author Artem Ananiev
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    53
 * @author Anton Tarasov
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    54
 */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    55
@SuppressWarnings("serial")
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    56
public abstract class LightweightFrame extends Frame {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    57
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    58
    /**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    59
     * Constructs a new, initially invisible {@code LightweightFrame}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    60
     * instance.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    61
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    62
    public LightweightFrame() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    63
        setUndecorated(true);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    64
        setResizable(true);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    65
        setEnabled(true);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    66
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    67
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
     * Blocks introspection of a parent window by this child.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    70
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    71
     * @return null
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    72
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    73
    @Override public final Container getParent() { return null; }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    74
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    75
    @Override public Graphics getGraphics() { return null; }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    76
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    77
    @Override public final boolean isResizable() { return true; }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    78
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    79
    // Block modification of any frame attributes, since they aren't
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    80
    // applicable for a lightweight frame.
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
    @Override public final void setTitle(String title) {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    83
    @Override public final void setIconImage(Image image) {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    84
    @Override public final void setIconImages(java.util.List<? extends Image> icons) {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    85
    @Override public final void setMenuBar(MenuBar mb) {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    86
    @Override public final void setResizable(boolean resizable) {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    87
    @Override public final void remove(MenuComponent m) {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    88
    @Override public final void toFront() {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    89
    @Override public final void toBack() {}
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    90
28231
b608ffcaed74 8066621: Suppress deprecation warnings in java.desktop module
darcy
parents: 26353
diff changeset
    91
    @SuppressWarnings("deprecation")
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    92
    @Override public void addNotify() {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    93
        synchronized (getTreeLock()) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    94
            if (getPeer() == null) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    95
                SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    96
                try {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    97
                    setPeer(stk.createLightweightFrame(this));
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    98
                } catch (Exception e) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
    99
                    throw new RuntimeException(e);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   100
                }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   101
            }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   102
            super.addNotify();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   103
        }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   104
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   105
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   106
    private void setPeer(final FramePeer p) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   107
        AWTAccessor.getComponentAccessor().setPeer(this, p);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   108
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   109
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   110
    /**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   111
     * Requests the peer to emulate activation or deactivation of the
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   112
     * frame. Peers should override this method if they are to implement
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   113
     * this functionality.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   114
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   115
     * @param activate if <code>true</code>, activates the frame;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   116
     *                 otherwise, deactivates the frame
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   117
     */
28231
b608ffcaed74 8066621: Suppress deprecation warnings in java.desktop module
darcy
parents: 26353
diff changeset
   118
    @SuppressWarnings("deprecation")
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   119
    public void emulateActivation(boolean activate) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   120
        ((FramePeer)getPeer()).emulateActivation(activate);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   121
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   122
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
     * Delegates the focus grab action to the client (embedding) application.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   125
     * The method is called by the AWT grab machinery.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   126
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   127
     * @see SunToolkit#grab(java.awt.Window)
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   128
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   129
    public abstract void grabFocus();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   130
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   131
    /**
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   132
     * Delegates the focus ungrab action to the client (embedding) application.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   133
     * The method is called by the AWT grab machinery.
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   134
     *
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   135
     * @see SunToolkit#ungrab(java.awt.Window)
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   136
     */
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   137
    public abstract void ungrabFocus();
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   138
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   139
    /**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   140
     * Returns the scale factor of this frame. The default value is 1.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   141
     *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   142
     * @return the scale factor
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   143
     * @see #notifyDisplayChanged(int)
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   144
     */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   145
    public abstract int getScaleFactor();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   146
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   147
    /**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   148
     * Called when display of the hosted frame is changed.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   149
     *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   150
     * @param scaleFactor the scale factor
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   151
     */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   152
    public abstract void notifyDisplayChanged(int scaleFactor);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   153
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   154
    /**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   155
     * Host window absolute bounds.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   156
     */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   157
    private int hostX, hostY, hostW, hostH;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   158
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   159
    /**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   160
     * Returns the absolute bounds of the host (embedding) window.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   161
     *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   162
     * @return the host window bounds
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   163
     */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   164
    public Rectangle getHostBounds() {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   165
        if (hostX == 0 && hostY == 0 && hostW == 0 && hostH == 0) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   166
            // The client app is probably unaware of the setHostBounds.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   167
            // A safe fall-back:
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   168
            return getBounds();
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   169
        }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   170
        return new Rectangle(hostX, hostY, hostW, hostH);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   171
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   172
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   173
    /**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   174
     * Sets the absolute bounds of the host (embedding) window.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   175
     */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   176
    public void setHostBounds(int x, int y, int w, int h) {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   177
        hostX = x;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   178
        hostY = y;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   179
        hostW = w;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   180
        hostH = h;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents: 15983
diff changeset
   181
    }
26342
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   182
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   183
    /**
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   184
     * Create a drag gesture recognizer for the lightweight frame.
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   185
     */
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   186
    public abstract <T extends DragGestureRecognizer> T createDragGestureRecognizer(
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   187
            Class<T> abstractRecognizerClass,
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   188
            DragSource ds, Component c, int srcActions,
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   189
            DragGestureListener dgl);
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   190
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   191
    /**
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   192
     * Create a drag source context peer for the lightweight frame.
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   193
     */
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   194
    public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   195
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   196
    /**
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   197
     * Adds a drop target to the lightweight frame.
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   198
     */
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   199
    public abstract void addDropTarget(DropTarget dt);
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   200
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   201
    /**
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   202
     * Removes a drop target from the lightweight frame.
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   203
     */
3637212ae8f2 8049065: [JLightweightFrame] Support DnD for SwingNode
anthony
parents: 25195
diff changeset
   204
    public abstract void removeDropTarget(DropTarget dt);
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents:
diff changeset
   205
}