1 /*****************************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one                *
3  * or more contributor license agreements.  See the NOTICE file              *
4  * distributed with this work for additional information                     *
5  * regarding copyright ownership.  The ASF licenses this file                *
6  * to you under the Apache License, Version 2.0 (the                         *
7  * "License"); you may not use this file except in compliance                *
8  * with the License.  You may obtain a copy of the License at                *
9  *                                                                           *
10  *     http://www.apache.org/licenses/LICENSE-2.0                            *
11  *                                                                           *
12  * Unless required by applicable law or agreed to in writing,                *
13  * software distributed under the License is distributed on an               *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY                    *
15  * KIND, either express or implied.  See the License for the                 *
16  * specific language governing permissions and limitations                   *
17  * under the License.                                                        *
18  *                                                                           *
19  * This file is part of the BeanShell Java Scripting distribution.           *
20  * Documentation and updates may be found at http://www.beanshell.org/       *
21  * Patrick Niemeyer (pat@pat.net)                                            *
22  * Author of Learning Java, O'Reilly & Associates                            *
23  *                                                                           *
24  *****************************************************************************/
25 
26 package bsh.util;
27 
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.io.*;
31 import java.util.Vector;
32 import bsh.*;
33 
34 
35 /**
36 	Misc utilities for the bsh.util package.
37 	Nothing in the core language (bsh package) should depend on this.
38 	Note: that promise is currently broken... fix it.
39 */
40 public class Util
41 {
42 	/*
43 	public static ConsoleInterface makeConsole() {
44 		if ( bsh.Capabilities.haveSwing() )
45 			return new JConsole();
46 		else
47 			return new AWTConsole();
48 	}
49 	*/
50 
51 	static Window splashScreen;
52 	/*
53 		This could live in the desktop script.
54 		However we'd like to get it on the screen as quickly as possible.
55 	*/
startSplashScreen()56 	public static void startSplashScreen()
57 	{
58 		int width=275,height=148;
59 		Window win=new Window( new Frame() );
60         win.pack();
61         BshCanvas can=new BshCanvas();
62         can.setSize( width, height ); // why is this necessary?
63         Toolkit tk=Toolkit.getDefaultToolkit();
64         Dimension dim=tk.getScreenSize();
65         win.setBounds(
66 			dim.width/2-width/2, dim.height/2-height/2, width, height );
67         win.add("Center", can);
68         Image img=tk.getImage(
69 			Interpreter.class.getResource("/bsh/util/lib/splash.gif") );
70         MediaTracker mt=new MediaTracker(can);
71         mt.addImage(img,0);
72         try { mt.waitForAll(); } catch ( Exception e ) { }
73         Graphics gr=can.getBufferedGraphics();
74         gr.drawImage(img, 0, 0, can);
75         win.setVisible(true);
76         win.toFront();
77 		splashScreen = win;
78 	}
79 
endSplashScreen()80 	public static void endSplashScreen() {
81 		if ( splashScreen != null )
82 			splashScreen.dispose();
83 	}
84 
85 }
86