KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > piratepete > dbpirate > DBPirate


1 package com.piratepete.dbpirate;
2
3 import java.awt.BorderLayout JavaDoc;
4 import java.awt.event.KeyEvent JavaDoc;
5
6 import javax.swing.Action JavaDoc;
7 import javax.swing.ImageIcon JavaDoc;
8 import javax.swing.*;
9
10 import com.piratepete.dbpirate.ui.MainWindow;
11 import com.piratepete.dbpirate.ui.MainToolBar;
12 import com.piratepete.dbpirate.ui.MainMenu;
13 import com.piratepete.dbpirate.ui.SplashScreen;
14
15 import com.piratepete.dbpirate.ui.actions.NewConnectionAction;
16
17 /**
18  * ApplicationMain Class
19  * Copyright (C) 2003 Jeremy Whitlock, David L. Whitehurst<p>
20  *
21  * This program is free software; you can redistribute it and/or
22  * modify it under the terms of the GNU General Public License
23  * as published by the Free Software Foundation; either version 2
24  * of the License, or (at your option) any later version.<p>
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  * GNU General Public License for more details.<p>
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, write to the Free Software
33  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.<p>
34  *
35  * <a HREF="http://www.piratepetesoftware.com">piratepetesoftware.com</a><br>
36  * <a HREF="mailto:dlwhitehurst@comcast.net">dlwhitehurst@comcast.net</a>
37  *
38  * @version 1.1.0
39  */

40 public class DBPirate {
41     
42     public static ApplicationManager appManager = null;
43     
44     /**
45      * Constructor
46      *
47      */

48     public DBPirate()
49     {
50         // create helper objects
51
appManager = new ApplicationManager();
52         
53         // Splash Screen
54
splash = new SplashScreen();
55
56         //progressBar maximum is NUMLOOPS (100)
57
for(int i = 0; i < 7; i++) {
58             updateStatus(i);
59             try {
60                 Thread.sleep(500);
61             } catch (InterruptedException JavaDoc ie) {
62                 ie.printStackTrace();
63             }
64         }
65         
66         // Create application window and set look-feel
67
MainWindow appWindow = new MainWindow("DBPirate v1.0a");
68         appWindow.setPLAF();
69         
70         // Create menu and toolbar
71
MainMenu appMenu = new MainMenu(actions, appWindow);
72         MainToolBar toolbar = new MainToolBar(actions);
73         
74         // Lay out the content pane.
75
JPanel contentPane = new JPanel();
76         contentPane.setLayout(new BorderLayout JavaDoc());
77         appWindow.setContentPane(contentPane);
78         
79         // Create the desktop
80
desktop = new JDesktopPane(); //a specialized layered pane
81
contentPane.add(desktop, BorderLayout.CENTER);
82         contentPane.add(toolbar, BorderLayout.NORTH);
83         appWindow.setContentPane(contentPane);
84         setBackgroundImage(desktop);
85         
86         appWindow.setJMenuBar(appMenu);
87         //appWindow.getContentPane().setBackground(Color.GRAY);
88
appWindow.setVisible(true);
89         appWindow.Maximize();
90
91         // hide splash
92
hideSplashScreen();
93         splash = null;
94         
95     }
96
97     /**
98      * Method to hide Splash screen
99      *
100      */

101     public static void hideSplashScreen()
102     {
103         if(splash != null)
104         {
105             splash.dispose();
106             splash = null;
107         }
108     }
109     
110     /**
111      * Method to increment Splash progress indicator
112      *
113      */

114     public void updateStatus(int increment) {
115         // Progress Splash
116
if(splash != null) {
117             splash.advance();
118         }
119     }
120     
121     /**
122      * Application Main
123      *
124      */

125     public static void main(String JavaDoc[] args)
126     {
127         DBPirate dbpirate = new DBPirate();
128         
129         // dbpirate.initRegistry();
130
}
131
132     /**
133      * Method to set a JPG or GIF image on desktop within
134      * the main Application
135      */

136     protected void setBackgroundImage(JDesktopPane desktop)
137     {
138         ImageIcon JavaDoc icon = new ImageIcon JavaDoc(getClass().getResource("/com/piratepete/dbpirate/ui/images/flag.jpg"));
139         JLabel label = new JLabel(icon);
140         label.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
141         desktop.add(label, new Integer JavaDoc(Integer.MIN_VALUE));
142     }
143
144
145     /**
146      * Method to create newConnection action
147      *
148      */

149     private Action JavaDoc newConnectAction = new NewConnectionAction("New",
150             new ImageIcon JavaDoc(this.getClass().getClass().getResource("/com/piratepete/dbpirate/ui/images/connect.gif")),
151             "New Connection",new Integer JavaDoc(KeyEvent.VK_N));
152     
153     private Action JavaDoc[] actions = { newConnectAction };
154     private JDesktopPane desktop;
155     private static SplashScreen splash;
156     
157 }
158
Popular Tags