01: package org.tp23.demo;
02:
03: import java.io.File;
04: import java.io.FileInputStream;
05: import java.io.FileNotFoundException;
06: import java.io.IOException;
07: import java.io.InputStream;
08: import java.util.Iterator;
09: import java.util.Properties;
10:
11: import javax.swing.ImageIcon;
12: import javax.swing.JOptionPane;
13: import javax.swing.JFrame;
14:
15: /**
16: *
17: * <p>Title: Example Application</p>
18: * <p>Description: Prints Hello World, trys to do it in a pop up box
19: * if a Throwable is thrown (e.g. no X) it prints to System.out</p>
20: * <p>Copyright: Copyright (c) 2004</p>
21: * <p>Company: tp23</p>
22: * @author Paul Hinds
23: * @version 1.0
24: */
25: public class Demonstration {
26: private static ImageIcon icon;
27: static {
28: try {
29: InputStream in = Demonstration.class
30: .getResourceAsStream("/resources/demo.png");
31: byte[] data = new byte[11437];
32: for (int i = 0; i < data.length; i++) {
33: data[i] = (byte) in.read();
34: }
35: icon = new ImageIcon(data);
36: } catch (IOException e) {
37: e.printStackTrace();
38: }
39: }
40:
41: public static void main(String[] args) {
42: try {
43: JOptionPane.showMessageDialog(null, "Demo Application \n\n"
44: + "Deployed with: "
45: + "http://antinstaller.sourceforge.net \n"
46: + "Built by: " + "http://ant.apache.org \n"
47: + "See also: "
48: + "http://httpfileserver.sourceforge.net \n\n"
49: + "This project is Apache licensed \n\n"
50: + "Properties selected while installing \n\n"
51: + initProps(), "About - Demo App",
52: JOptionPane.INFORMATION_MESSAGE, icon);
53: } catch (Throwable t) {
54: System.out.println("Hello World");
55: }
56: System.exit(0);
57: }
58:
59: private static String initProps() {
60: StringBuffer userProperties = new StringBuffer();
61: try {
62: Properties props = new Properties();
63: props.load(new FileInputStream(new File(
64: "./config/demo.properties")));
65: Iterator iter = props.keySet().iterator();
66: while (iter.hasNext()) {
67: String key = (String) iter.next();
68: userProperties.append(key).append("=").append(
69: props.getProperty(key)).append('\n');
70: }
71: } catch (FileNotFoundException e) {
72: e.printStackTrace();
73: } catch (IOException e) {
74: e.printStackTrace();
75: }
76: return userProperties.toString();
77: }
78:
79: }
|