01: /*
02: * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.awt.X11;
27:
28: import sun.awt.EmbeddedFrame;
29: import java.awt.*;
30: import java.awt.AWTKeyStroke;
31:
32: public class XEmbeddedFrame extends EmbeddedFrame {
33:
34: long handle;
35:
36: public XEmbeddedFrame() {
37: }
38:
39: // handle should be a valid X Window.
40: public XEmbeddedFrame(long handle) {
41: this (handle, false);
42: }
43:
44: // Handle is the valid X window
45: public XEmbeddedFrame(long handle, boolean supportsXEmbed,
46: boolean isTrayIconWindow) {
47: super (handle, supportsXEmbed);
48:
49: if (isTrayIconWindow) {
50: XTrayIconPeer.suppressWarningString(this );
51: }
52:
53: this .handle = handle;
54: if (handle != 0) { // Has actual parent
55: addNotify();
56: if (!isTrayIconWindow) {
57: show();
58: }
59: }
60: }
61:
62: public void addNotify() {
63: if (getPeer() == null) {
64: XToolkit toolkit = (XToolkit) Toolkit.getDefaultToolkit();
65: setPeer(toolkit.createEmbeddedFrame(this ));
66: }
67: super .addNotify();
68: }
69:
70: public XEmbeddedFrame(long handle, boolean supportsXEmbed) {
71: this (handle, supportsXEmbed, false);
72: }
73:
74: protected boolean traverseOut(boolean direction) {
75: XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
76: if (direction == FORWARD) {
77: xefp.traverseOutForward();
78: } else {
79: xefp.traverseOutBackward();
80: }
81: return true;
82: }
83:
84: public void registerAccelerator(AWTKeyStroke stroke) {
85: XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
86: if (xefp != null) {
87: xefp.registerAccelerator(stroke);
88: }
89: }
90:
91: public void unregisterAccelerator(AWTKeyStroke stroke) {
92: XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
93: if (xefp != null) {
94: xefp.unregisterAccelerator(stroke);
95: }
96: }
97: }
|