1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.lwawt; 27 28 import java.awt.Graphics; 29 import java.awt.Insets; 30 import java.awt.Point; 31 import java.awt.Rectangle; 32 import java.awt.Window; 33 import java.awt.dnd.DropTarget; 34 import sun.awt.CausedFocusEvent; 35 import sun.awt.LightweightFrame; 36 37 public class LWLightweightFramePeer extends LWWindowPeer { 38 39 public LWLightweightFramePeer(LightweightFrame target, 40 PlatformComponent platformComponent, 41 PlatformWindow platformWindow) 42 { 43 super(target, platformComponent, platformWindow, LWWindowPeer.PeerType.LW_FRAME); 44 } 45 46 @Override 47 public Graphics getGraphics() { 48 return ((LightweightFrame)getTarget()).getGraphics(); 49 } 50 51 @Override 52 protected void setVisibleImpl(final boolean visible) { 53 } 54 55 @Override 56 public boolean requestWindowFocus(CausedFocusEvent.Cause cause) { 57 if (!focusAllowedFor()) { 58 return false; 59 } 60 if (getPlatformWindow().rejectFocusRequest(cause)) { 61 return false; 62 } 63 64 Window opposite = LWKeyboardFocusManagerPeer.getInstance(). 65 getCurrentFocusedWindow(); 66 67 changeFocusedWindow(true, opposite); 68 69 return true; 70 } 71 72 @Override 73 public Point getLocationOnScreen() { 74 Rectangle bounds = getBounds(); 75 return new Point(bounds.x, bounds.y); // todo 76 } 77 78 @Override 79 public Insets getInsets() { 80 return new Insets(0, 0, 0, 0); 81 } 82 83 @Override 84 public void setBounds(int x, int y, int w, int h, int op) { 85 setBounds(x, y, w, h, op, true, false); 86 } 87 88 @Override 89 public void updateCursorImmediately() { 90 // TODO: tries to switch to the awt/fx toolkit thread and causes a deadlock on macosx 91 } 92 93 @Override 94 public void addDropTarget(DropTarget dt) { 95 } 96 97 @Override 98 public void removeDropTarget(DropTarget dt) { 99 } 100 }