src/share/classes/sun/awt/LightweightFrame.java

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 

  28 import java.awt.Container;
  29 import java.awt.Frame;
  30 import java.awt.Graphics;
  31 import java.awt.Image;
  32 import java.awt.MenuBar;
  33 import java.awt.MenuComponent;
  34 import java.awt.Rectangle;
  35 import java.awt.Toolkit;







  36 import java.awt.peer.FramePeer;
  37 
  38 /**
  39  * The class provides basic functionality for a lightweight frame
  40  * implementation. A subclass is expected to provide painting to an
  41  * offscreen image and access to it. Thus it can be used for lightweight
  42  * embedding.
  43  *
  44  * @author Artem Ananiev
  45  * @author Anton Tarasov
  46  */
  47 @SuppressWarnings("serial")
  48 public abstract class LightweightFrame extends Frame {
  49 
  50     /**
  51      * Constructs a new, initially invisible {@code LightweightFrame}
  52      * instance.
  53      */
  54     public LightweightFrame() {
  55         setUndecorated(true);


 152      * @return the host window bounds
 153      */
 154     public Rectangle getHostBounds() {
 155         if (hostX == 0 && hostY == 0 && hostW == 0 && hostH == 0) {
 156             // The client app is probably unaware of the setHostBounds.
 157             // A safe fall-back:
 158             return getBounds();
 159         }
 160         return new Rectangle(hostX, hostY, hostW, hostH);
 161     }
 162 
 163     /**
 164      * Sets the absolute bounds of the host (embedding) window.
 165      */
 166     public void setHostBounds(int x, int y, int w, int h) {
 167         hostX = x;
 168         hostY = y;
 169         hostW = w;
 170         hostH = h;
 171     }























 172 }


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.Component;
  29 import java.awt.Container;
  30 import java.awt.Frame;
  31 import java.awt.Graphics;
  32 import java.awt.Image;
  33 import java.awt.MenuBar;
  34 import java.awt.MenuComponent;
  35 import java.awt.Rectangle;
  36 import java.awt.Toolkit;
  37 import java.awt.dnd.DragGestureEvent;
  38 import java.awt.dnd.DragGestureListener;
  39 import java.awt.dnd.DragGestureRecognizer;
  40 import java.awt.dnd.DragSource;
  41 import java.awt.dnd.DropTarget;
  42 import java.awt.dnd.InvalidDnDOperationException;
  43 import java.awt.dnd.peer.DragSourceContextPeer;
  44 import java.awt.peer.FramePeer;
  45 
  46 /**
  47  * The class provides basic functionality for a lightweight frame
  48  * implementation. A subclass is expected to provide painting to an
  49  * offscreen image and access to it. Thus it can be used for lightweight
  50  * embedding.
  51  *
  52  * @author Artem Ananiev
  53  * @author Anton Tarasov
  54  */
  55 @SuppressWarnings("serial")
  56 public abstract class LightweightFrame extends Frame {
  57 
  58     /**
  59      * Constructs a new, initially invisible {@code LightweightFrame}
  60      * instance.
  61      */
  62     public LightweightFrame() {
  63         setUndecorated(true);


 160      * @return the host window bounds
 161      */
 162     public Rectangle getHostBounds() {
 163         if (hostX == 0 && hostY == 0 && hostW == 0 && hostH == 0) {
 164             // The client app is probably unaware of the setHostBounds.
 165             // A safe fall-back:
 166             return getBounds();
 167         }
 168         return new Rectangle(hostX, hostY, hostW, hostH);
 169     }
 170 
 171     /**
 172      * Sets the absolute bounds of the host (embedding) window.
 173      */
 174     public void setHostBounds(int x, int y, int w, int h) {
 175         hostX = x;
 176         hostY = y;
 177         hostW = w;
 178         hostH = h;
 179     }
 180 
 181     /**
 182      * Create a drag gesture recognizer for the lightweight frame.
 183      */
 184     public abstract <T extends DragGestureRecognizer> T createDragGestureRecognizer(
 185             Class<T> abstractRecognizerClass,
 186             DragSource ds, Component c, int srcActions,
 187             DragGestureListener dgl);
 188 
 189     /**
 190      * Create a drag source context peer for the lightweight frame.
 191      */
 192     public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
 193 
 194     /**
 195      * Adds a drop target to the lightweight frame.
 196      */
 197     public abstract void addDropTarget(DropTarget dt);
 198 
 199     /**
 200      * Removes a drop target from the lightweight frame.
 201      */
 202     public abstract void removeDropTarget(DropTarget dt);
 203 }