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