01: package org.enhydra.jawe;
02:
03: import java.awt.BorderLayout;
04: import java.awt.Color;
05: import java.awt.event.MouseAdapter;
06: import java.awt.event.MouseEvent;
07: import java.net.URL;
08:
09: import javax.swing.ImageIcon;
10: import javax.swing.JEditorPane;
11: import javax.swing.JLabel;
12: import javax.swing.JPanel;
13: import javax.swing.JWindow;
14: import javax.swing.SwingConstants;
15:
16: public class JaWESplash extends JWindow {
17:
18: public JaWESplash() {
19: URL imageURL = null;
20: String image = JaWEManager.getSplashScreenImage();
21: if (image != null && !"".equals(image)) {
22: imageURL = JaWEManager.class.getClassLoader().getResource(
23: image);
24: }
25:
26: JLabel l = null;
27: if (imageURL != null) {
28: l = new JLabel(new ImageIcon(imageURL));
29: } else {
30: l = new JLabel("");
31: }
32: getContentPane().add(l, BorderLayout.CENTER);
33:
34: Utils.center(this , 100, 200);
35:
36: addMouseListener(new MouseAdapter() {
37: public void mousePressed(MouseEvent e) {
38: hideSplash();
39: }
40: });
41: setVisible(true);
42: }
43:
44: public void hideSplash() {
45: if (isVisible()) {
46: setVisible(false);
47: dispose();
48: }
49: }
50:
51: public static JPanel getSplashPanel() {
52: Hyperactive ha = new Hyperactive();
53:
54: JPanel p = new JPanel();
55: p.setLayout(new BorderLayout());
56: p.setBackground(Color.WHITE);
57:
58: URL imageURL = null;
59:
60: // logo
61: String image = JaWEManager.getSplashScreenImage();
62: if (image != null && !"".equals(image)) {
63: imageURL = JaWEManager.class.getClassLoader().getResource(
64: image);
65: }
66: JLabel logo = null;
67: if (imageURL != null) {
68: logo = new JLabel(new ImageIcon(imageURL),
69: SwingConstants.CENTER);
70: } else {
71: logo = new JLabel("", SwingConstants.CENTER);
72: }
73:
74: JEditorPane text = new JEditorPane();
75: text.setAlignmentX(CENTER_ALIGNMENT);
76: text.setAlignmentY(TOP_ALIGNMENT);
77: text.addHyperlinkListener(ha);
78: text.setContentType("text/html");
79: text.setOpaque(false);
80: String t = "<html><p align=center><b>Version: "
81: + JaWEManager.getVersion() + "-"
82: + JaWEManager.getRelease() + "</b>" + "<br>Build Id: "
83: + JaWEManager.getBuildEdition()
84: + JaWEManager.getBuildEditionSuffix() + "-"
85: + JaWEManager.getBuildNo() + "<br><br>"
86: + JaWEManager.getAboutMsg();
87:
88: text.setText(t);
89: text.setEditable(false);
90:
91: p.add(logo, BorderLayout.NORTH);
92: p.add(text, BorderLayout.CENTER);
93:
94: return p;
95: }
96: }
|