KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > base > MainApp


1 package zirc.base ;
2
3 import java.awt.* ;
4 import javax.swing.* ;
5
6 import zirc.gui.* ;
7
8 //zIrc, irc client.
9
// Copyright (C) 2004 CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com
10
//
11
// This program is free software; you can redistribute it and/or
12
// modify it under the terms of the GNU General Public License
13
// as published by the Free Software Foundation; either version 2
14
// of the License, or (at your option) any later version.
15
//
16
// This program is distributed in the hope that it will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU General Public License for more details.
20

21 /**
22  * <p>Title: MainApp</p>
23  * <p>Description:</p>
24  * <p>Copyright: Copyright (c) 2004</p>
25  * <p>Company: CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
26  * @version 1.0
27  */

28
29 public class MainApp
30 {
31   private boolean packFrame = false ;
32
33   //Construct the application
34
public MainApp()
35   {
36     MainFrame frame = new MainFrame() ;
37     //Validate frames that have preset sizes
38
//Pack frames that have useful preferred size info, e.g. from their layout
39
if (packFrame)
40     {
41       frame.pack() ;
42     }
43     else
44     {
45       frame.validate() ;
46     }
47     //Center the window
48
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize() ;
49     Dimension frameSize = frame.getSize() ;
50     if (frameSize.height > screenSize.height)
51     {
52       frameSize.height = screenSize.height ;
53     }
54     if (frameSize.width > screenSize.width)
55     {
56       frameSize.width = screenSize.width ;
57     }
58     frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2) ;
59     frame.setVisible(true) ;
60   }
61
62   //Main method
63
public static void main(String JavaDoc[] args)
64   {
65     try
66     {
67       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) ;
68     }
69     catch (Exception JavaDoc ex)
70     {
71       ex.printStackTrace() ;
72     }
73     new MainApp() ;
74   }
75 }
76
Popular Tags