1 | package org.tp23.demo;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.io.FileInputStream;
|
---|
5 | import java.io.FileNotFoundException;
|
---|
6 | import java.io.IOException;
|
---|
7 | import java.io.InputStream;
|
---|
8 | import java.util.Iterator;
|
---|
9 | 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.getResourceAsStream("/resources/demo.png");
|
---|
30 | byte[] data = new byte[11437];
|
---|
31 | for (int i = 0; i < data.length; i++) {
|
---|
32 | data[i]=(byte)in.read();
|
---|
33 | }
|
---|
34 | icon = new ImageIcon(data);
|
---|
35 | }
|
---|
36 | catch (IOException e) {
|
---|
37 | e.printStackTrace();
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | public static void main(String[] args) {
|
---|
42 | try{
|
---|
43 | JOptionPane.showMessageDialog(null,
|
---|
44 | "Demo Application \n\n" +
|
---|
45 | "Deployed with: "+
|
---|
46 | "http://antinstaller.sourceforge.net \n" +
|
---|
47 | "Built by: "+
|
---|
48 | "http://ant.apache.org \n" +
|
---|
49 | "See also: "+
|
---|
50 | "http://httpfileserver.sourceforge.net \n\n" +
|
---|
51 | "This project is Apache licensed \n\n" +
|
---|
52 | "Properties selected while installing \n\n" +
|
---|
53 | initProps(),
|
---|
54 | "About - Demo App",
|
---|
55 | JOptionPane.INFORMATION_MESSAGE,
|
---|
56 | icon);
|
---|
57 | }catch(Throwable t){
|
---|
58 | System.out.println("Hello World");
|
---|
59 | }
|
---|
60 | System.exit(0);
|
---|
61 | }
|
---|
62 | private static String initProps() {
|
---|
63 | StringBuffer userProperties = new StringBuffer();
|
---|
64 | try {
|
---|
65 | Properties props = new Properties();
|
---|
66 | props.load(new FileInputStream(new File("./config/demo.properties")));
|
---|
67 | Iterator iter = props.keySet().iterator();
|
---|
68 | while(iter.hasNext()){
|
---|
69 | String key = (String)iter.next();
|
---|
70 | userProperties.append(key)
|
---|
71 | .append("=")
|
---|
72 | .append(props.getProperty(key))
|
---|
73 | .append('\n');
|
---|
74 | }
|
---|
75 | }
|
---|
76 | catch (FileNotFoundException e) {
|
---|
77 | e.printStackTrace();
|
---|
78 | }
|
---|
79 | catch (IOException e) {
|
---|
80 | e.printStackTrace();
|
---|
81 | }
|
---|
82 | return userProperties.toString();
|
---|
83 | }
|
---|
84 |
|
---|
85 | }
|
---|