< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XEmbeddingContainer.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2012, 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


  29 import java.util.HashMap;
  30 import java.awt.event.KeyEvent;
  31 import java.lang.reflect.*;
  32 import sun.awt.AWTAccessor;
  33 
  34 public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher {
  35     HashMap<Long, java.awt.peer.ComponentPeer> children = new HashMap<>();
  36 
  37     XEmbeddingContainer() {
  38     }
  39 
  40     XWindow embedder;
  41     void install(XWindow embedder) {
  42         this.embedder = embedder;
  43         XToolkit.addEventDispatcher(embedder.getWindow(), this);
  44     }
  45     void deinstall() {
  46         XToolkit.removeEventDispatcher(embedder.getWindow(), this);
  47     }
  48 

  49     void add(long child) {
  50         if (checkXEmbed(child)) {
  51             Component proxy = createChildProxy(child);
  52             ((Container)embedder.getTarget()).add("Center", proxy);
  53             if (proxy.getPeer() != null) {
  54                 children.put(Long.valueOf(child), proxy.getPeer());
  55             }
  56         }
  57     }
  58 
  59     Component createChildProxy(long child) {
  60         return new XEmbedChildProxy(this, child);
  61     }
  62     void notifyChildEmbedded(long child) {
  63         sendMessage(child, XEMBED_EMBEDDED_NOTIFY, embedder.getWindow(), XEMBED_VERSION, 0);
  64     }
  65 
  66     void childResized(Component child) {
  67     }
  68 


   1 /*
   2  * Copyright (c) 2003, 2014, 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


  29 import java.util.HashMap;
  30 import java.awt.event.KeyEvent;
  31 import java.lang.reflect.*;
  32 import sun.awt.AWTAccessor;
  33 
  34 public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher {
  35     HashMap<Long, java.awt.peer.ComponentPeer> children = new HashMap<>();
  36 
  37     XEmbeddingContainer() {
  38     }
  39 
  40     XWindow embedder;
  41     void install(XWindow embedder) {
  42         this.embedder = embedder;
  43         XToolkit.addEventDispatcher(embedder.getWindow(), this);
  44     }
  45     void deinstall() {
  46         XToolkit.removeEventDispatcher(embedder.getWindow(), this);
  47     }
  48 
  49     @SuppressWarnings("deprecation")
  50     void add(long child) {
  51         if (checkXEmbed(child)) {
  52             Component proxy = createChildProxy(child);
  53             ((Container)embedder.getTarget()).add("Center", proxy);
  54             if (proxy.getPeer() != null) {
  55                 children.put(Long.valueOf(child), proxy.getPeer());
  56             }
  57         }
  58     }
  59 
  60     Component createChildProxy(long child) {
  61         return new XEmbedChildProxy(this, child);
  62     }
  63     void notifyChildEmbedded(long child) {
  64         sendMessage(child, XEMBED_EMBEDDED_NOTIFY, embedder.getWindow(), XEMBED_VERSION, 0);
  65     }
  66 
  67     void childResized(Component child) {
  68     }
  69 


< prev index next >