1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 import java.awt.*; 25 import java.lang.reflect.*; 26 27 public class SystemWindowAdapter 28 { createFrame( int windowHandle )29 static public java.awt.Frame createFrame( int windowHandle ) 30 { 31 String aOS = (String) System.getProperty( "os.name" ); 32 java.awt.Frame aFrame = null; 33 34 if( aOS.startsWith( "SunOS" ) ) 35 { 36 try 37 { 38 Class aClass = Class.forName( "sun.awt.motif.MEmbeddedFrame" ); 39 40 if( aClass != null ) 41 { 42 try 43 { 44 Constructor aCtor = aClass.getConstructor( new Class[] { long.class, boolean.class } ); 45 46 if( aCtor != null ) 47 { 48 aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ), 49 new Boolean( false ) } ); 50 } 51 } 52 catch( Exception e ) 53 { 54 } 55 56 if( aFrame == null ) 57 { 58 try 59 { 60 Constructor aCtor = aClass.getConstructor( new Class[] { long.class } ); 61 62 if( aCtor != null ) 63 { 64 aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ) } ); 65 } 66 } 67 catch( Exception e ) 68 { 69 } 70 } 71 } 72 } 73 catch( Exception e ) 74 { 75 } 76 } 77 else 78 { 79 try 80 { 81 Class aClass = Class.forName( "sun.awt.motif.MEmbeddedFrame" ); 82 83 if( aClass != null ) 84 { 85 Constructor aCtor = aClass.getConstructor( new Class[] { long.class } ); 86 87 if( aCtor != null ) 88 { 89 aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ) } ); 90 } 91 } 92 } 93 catch( Exception e ) 94 { 95 } 96 97 if( aFrame == null ) 98 { 99 try 100 { 101 Class aClass = Class.forName( "sun.awt.X11.XEmbeddedFrame" ); 102 103 if( aClass != null ) 104 { 105 Constructor aCtor = aClass.getConstructor( new Class[] { long.class } ); 106 107 if( aCtor != null ) 108 aFrame = (java.awt.Frame) aCtor.newInstance( new Object[] { new Long( windowHandle ) } ); 109 } 110 } 111 catch( Exception e ) 112 { 113 } 114 } 115 } 116 117 return aFrame; 118 } 119 } 120