OSDN Git Service

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/filelock/trunk@17 c6214a2a-ec3a...
[filelock/repo.git] / filelock / src / main / lib / launch4j-2.1.5-win32 / demo / SimpleApp / src / net / sf / launch4j / example / SimpleApp.java
1 /*
2         Launch4j (http://launch4j.sourceforge.net/)
3         Cross-platform Java application wrapper for creating Windows native executables.
4
5         Copyright (C) 2004, 2006 Grzegorz Kowal
6
7         This program is free software; you can redistribute it and/or modify
8         it under the terms of the GNU General Public License as published by
9         the Free Software Foundation; either version 2 of the License, or
10         (at your option) any later version.
11
12         This program is distributed in the hope that it will be useful,
13         but WITHOUT ANY WARRANTY; without even the implied warranty of
14         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15         GNU General Public License for more details.
16
17         You should have received a copy of the GNU General Public License
18         along with this program; if not, write to the Free Software
19         Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 package net.sf.launch4j.example;
23
24 import java.awt.Dimension;
25 import java.awt.Toolkit;
26 import java.awt.event.WindowAdapter;
27 import java.awt.event.WindowEvent;
28
29 import javax.swing.JFrame;
30 import javax.swing.JMenu;
31 import javax.swing.JMenuBar;
32 import javax.swing.JMenuItem;
33 import javax.swing.JOptionPane;
34 import javax.swing.UIManager;
35
36 public class SimpleApp extends JFrame {
37     public SimpleApp(String[] args) {
38         super("Java Application");
39         final int inset = 100;
40         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
41                 setBounds (inset, inset,
42                                 screenSize.width - inset * 2, screenSize.height - inset * 2);
43
44                 JMenu menu = new JMenu("File");
45                 menu.add(new JMenuItem("Open"));
46                 menu.add(new JMenuItem("Save"));
47                 JMenuBar mb = new JMenuBar();
48                 mb.setOpaque(true);
49                 mb.add(menu);
50                 setJMenuBar(mb);
51
52                 this.addWindowListener(new WindowAdapter() {
53                 public void windowClosing(WindowEvent e) {
54                                 System.exit(0);
55                 }});
56                 setVisible(true);
57
58                 StringBuffer sb = new StringBuffer("Java version: ");
59                 sb.append(System.getProperty("java.version"));
60                 sb.append("\nJava home: ");
61                 sb.append(System.getProperty("java.home"));
62                 sb.append("\nCurrent dir: ");
63                 sb.append(System.getProperty("user.dir"));
64                 if (args.length > 0) {
65                         sb.append("\nArgs: ");
66                         for (int i = 0; i < args.length; i++) {
67                                 sb.append(args[i]);
68                                 sb.append(' ');
69                         }
70                 }
71                 JOptionPane.showMessageDialog(this,
72                                 sb.toString(),
73                                 "Info",
74                                 JOptionPane.INFORMATION_MESSAGE);
75     }
76
77         public static void setLAF() {
78                 JFrame.setDefaultLookAndFeelDecorated(true);
79                 Toolkit.getDefaultToolkit().setDynamicLayout(true);
80                 System.setProperty("sun.awt.noerasebackground","true");
81                 try {
82                         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
83                 } catch (Exception e) {
84                         System.err.println("Failed to set LookAndFeel");
85                 }
86         }
87
88         public static void main(String[] args) {
89                 setLAF();
90                 new SimpleApp(args);
91         }
92 }