View Javadoc

1   package com.bluecove.emu.gui;
2   
3   import java.awt.Dimension;
4   import java.awt.Toolkit;
5   import java.awt.Window;
6   import java.awt.event.ActionEvent;
7   
8   import javax.swing.AbstractAction;
9   import javax.swing.Action;
10  import javax.swing.JFrame;
11  import javax.swing.JMenu;
12  import javax.swing.JMenuBar;
13  import javax.swing.UIManager;
14  
15  public class BluecoveEmulatorUI extends JFrame {
16  
17  	/**
18  	 * Global static product identifier.
19  	 */
20  	public static final String VERSION_NUMBER = "0.1";
21  
22  	/**
23  	 * Holds the application title for dialogs.
24  	 */
25  	public static String APPTITLE = "Bluecove Emulator Monitor";
26  
27  	private Action exitAction;
28  	private Action aboutAction;
29  	
30  	private EmulatorPane emulatorPane;
31  	
32  	BluecoveEmulatorUI() {
33  
34  		try {
35  			UIManager
36  					.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
37  		} catch (Exception e) {
38  			e.printStackTrace();
39  		}
40  
41  		Toolkit tk = Toolkit.getDefaultToolkit();
42  		Dimension screenSize = tk.getScreenSize();
43  
44  		Window splashWindow = Splash.createSplashWindow();
45  
46  		splashWindow.setLocation(screenSize.width / 2
47  				- (splashWindow.getSize().width / 2), screenSize.height / 2
48  				- (splashWindow.getSize().height / 2));
49  		splashWindow.setVisible(true);
50  
51  		try {
52  			Thread.sleep(1000);
53  		} catch (InterruptedException e) {
54  			e.printStackTrace();
55  		}
56  
57  		createApplication();
58  		setBounds(50, 50, screenSize.width - 100, screenSize.height - 100);
59  		splashWindow.dispose();
60  		setVisible(true);
61  	}
62  
63  	private void createApplication() {
64  		createActions();
65  		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
66  		setTitle("Bluecove Emulator Monitor");
67  		setJMenuBar(createMenuBar());
68  		emulatorPane = new EmulatorPane();
69  		getContentPane().add(emulatorPane); 
70  	}
71  
72  	private void createActions() {
73  		exitAction = new AbstractAction("Exit") {
74  			public void actionPerformed(ActionEvent e) {
75  				System.exit(0);
76  			}
77  		};
78  		
79  		aboutAction = new AbstractAction("About") {
80  			public void actionPerformed(ActionEvent event) {
81  				Splash.createSplashDialog(BluecoveEmulatorUI.this);
82  			}
83  		};
84  	}
85  
86  	private JMenuBar createMenuBar() {
87  		JMenuBar menuBar = new JMenuBar();
88  		
89  		JMenu fileMenu = new JMenu("File");
90  		fileMenu.setMnemonic('F');
91  		menuBar.add(fileMenu);
92  		
93  		fileMenu.add(exitAction);
94  		
95  		JMenu helpMenu = new JMenu("Help");
96  		helpMenu.setMnemonic('H');
97  		menuBar.add(helpMenu);
98  		
99  		helpMenu.add(aboutAction);
100 		
101 		return menuBar;
102 	}
103 
104 	public static void main(String[] args) {
105 		new BluecoveEmulatorUI();
106 	}
107 }