Subversion Repositories svn.mios

Rev

Rev 873 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 873 Rev 874
Line 17... Line 17...
17
 * along with this application; if not, write to the Free Software
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
19
 */
20
20
21
import java.awt.Dimension;
21
import java.awt.Dimension;
-
 
22
import java.awt.Rectangle;
22
import java.awt.Toolkit;
23
import java.awt.Toolkit;
23
import java.awt.event.ActionEvent;
24
import java.awt.event.ActionEvent;
24
import java.awt.event.ActionListener;
25
import java.awt.event.ActionListener;
25
import java.awt.event.ContainerEvent;
26
import java.awt.event.ContainerEvent;
26
import java.awt.event.ContainerListener;
27
import java.awt.event.ContainerListener;
27
import java.awt.event.KeyEvent;
28
import java.awt.event.KeyEvent;
28
import java.awt.event.WindowAdapter;
29
import java.awt.event.WindowAdapter;
29
import java.awt.event.WindowEvent;
30
import java.awt.event.WindowEvent;
30
import java.awt.event.WindowListener;
-
 
31
import java.io.File;
31
import java.io.File;
32
32
33
import javax.swing.JApplet;
33
import javax.swing.JApplet;
34
import javax.swing.JFrame;
34
import javax.swing.JFrame;
-
 
35
import javax.swing.JMenu;
-
 
36
import javax.swing.JMenuBar;
35
import javax.swing.JMenuItem;
37
import javax.swing.JMenuItem;
-
 
38
import javax.swing.SwingUtilities;
36
import javax.swing.UIManager;
39
import javax.swing.UIManager;
37
40
38
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
41
import org.midibox.apps.miosstudio.gui.MIOSStudioGUI;
39
import org.midibox.apps.miosstudio.gui.xml.MIOSStudioGUIXML;
42
import org.midibox.apps.miosstudio.gui.xml.MIOSStudioGUIXML;
40
import org.midibox.utils.gui.DialogOwner;
43
import org.midibox.utils.gui.DialogOwner;
41
import org.midibox.utils.gui.ImageLoader;
44
import org.midibox.utils.gui.ImageLoader;
42
import org.midibox.utils.gui.SplashScreen;
45
import org.midibox.utils.gui.SplashScreen;
43
46
-
 
47
import com.apple.mrj.MRJApplicationUtils;
44
import sun.awt.WindowClosingListener;
48
import com.apple.mrj.MRJQuitHandler;
45
49
46
/**
50
/**
47
 * Driver class for launching MIOS Studio application. MIOS Studio can be
51
 * Driver class for launching MIOS Studio application. MIOS Studio can be
48
 * launched as an application or embedded in a a web page as an applet. When
52
 * launched as an application or embedded in a a web page as an applet. When
49
 * launched as an application, the app shows a splash screen and is launched
53
 * launched as an application, the app shows a splash screen and is launched
Line 188... Line 192...
188
192
189
        DialogOwner.setFrame(frame);
193
        DialogOwner.setFrame(frame);
190
194
191
        frame.setIconImage(ImageLoader.getImageIcon("ucIcon.png").getImage());
195
        frame.setIconImage(ImageLoader.getImageIcon("ucIcon.png").getImage());
192
196
193
        frame.setBounds(50, 50, (screenSize.width - 100),
197
        frame.setBounds(new Rectangle(0, 0, 0, 0));
-
 
198
194
                (screenSize.height - 100));
199
        frame.setVisible(true);
195
200
196
        final MIOSStudio miosStudio = new MIOSStudio();
201
        final MIOSStudio miosStudio = new MIOSStudio();
-
 
202
-
 
203
        frame.setContentPane(miosStudio);
197
204
198
        if (System.getProperty("mrj.version") == null) {
205
        if (System.getProperty("mrj.version") == null) {
199
206
200
            JMenuItem exitMenuItem = new JMenuItem("Exit");
207
            JMenuItem exitMenuItem = new JMenuItem("Exit");
201
            exitMenuItem.setMnemonic(KeyEvent.VK_X);
208
            exitMenuItem.setMnemonic(KeyEvent.VK_X);
Line 208... Line 215...
208
                   
215
209
                    System.exit(0);
216
                    System.exit(0);
210
                }
217
                }
211
            });
218
            });
212
           
219
213
            miosStudio.setJMenuBar(miosStudio.miosStudioGUI.createMenuBar());
220
            JMenuBar menuBar = miosStudio.miosStudioGUI.createMenuBar();
214
           
221
-
 
222
            JMenu fileMenu = (JMenu) menuBar.getComponent(0);
-
 
223
-
 
224
            fileMenu.add(exitMenuItem);
-
 
225
215
            miosStudio.miosStudioGUI.getFileMenu().add(exitMenuItem);
226
            miosStudio.setJMenuBar(menuBar);
216
           
227
217
            frame.addWindowListener(new WindowAdapter() {
228
            frame.addWindowListener(new WindowAdapter() {
218
                public void windowClosing(WindowEvent we) {
229
                public void windowClosing(WindowEvent we) {
219
230
220
                    miosStudio.destroy();
231
                    miosStudio.destroy();
Line 225... Line 236...
225
236
226
        } else {
237
        } else {
227
238
228
            frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
239
            frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
229
           
240
-
 
241
            MRJApplicationUtils.registerQuitHandler(new MRJQuitHandler() {
-
 
242
                public void handleQuit() {
230
            Runtime.getRuntime().addShutdownHook(new Thread() {
243
                    SwingUtilities.invokeLater(new Runnable() {
231
-
 
232
                public void run() {
244
                        public void run() {
233
                    miosStudio.destroy();
245
                            miosStudio.destroy();
234
                }
-
 
235
246
-
 
247
                            System.exit(0);
-
 
248
                        }
-
 
249
                    });
-
 
250
                    throw new IllegalStateException(
-
 
251
                            "Stop Pending User Confirmation");
-
 
252
                }
236
            });
253
            });
237
           
254
238
            if (UIManager.getLookAndFeel().getClass().getName().toString() == UIManager
255
            if (UIManager.getLookAndFeel().getClass().getName().toString() == UIManager
239
                    .getSystemLookAndFeelClassName()) {
256
                    .getSystemLookAndFeelClassName()) {
240
257
Line 246... Line 263...
246
                miosStudio
263
                miosStudio
247
                        .setJMenuBar(miosStudio.miosStudioGUI.createMenuBar());
264
                        .setJMenuBar(miosStudio.miosStudioGUI.createMenuBar());
248
            }
265
            }
249
        }
266
        }
250
       
267
-
 
268
        if (frame.getBounds() == new Rectangle(0, 0, 0, 0)) {
-
 
269
251
        frame.setContentPane(miosStudio);
270
            frame.setBounds(50, 50, (screenSize.width - 100),
-
 
271
                    (screenSize.height - 100));
-
 
272
        }
252
273
253
        if (!miosStudio.miosStudioGUI.isMDI()) {
274
        if (!miosStudio.miosStudioGUI.isMDI()) {
254
275
255
            frame.setResizable(false);
276
            frame.setResizable(false);
256
277
Line 272... Line 293...
272
                            frame.pack();
293
                            frame.pack();
273
294
274
                        }
295
                        }
275
                    });
296
                    });
276
297
277
        }
298
        } else {
278
299
279
        frame.setVisible(true);
300
            frame.validate();
-
 
301
        }
280
302
281
        splashScreen.setVisible(false);
303
        splashScreen.setVisible(false);
282
304
-
 
305
        frame.requestFocus();
283
    }
306
    }
284
307
285
}
308
}