KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > JaWEAboutDialog


1 /* JaWEAboutDialog.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  *
8  */

9
10 package org.enhydra.jawe;
11
12 import javax.swing.*;
13 import java.awt.*;
14 import java.awt.event.*;
15
16 import org.enhydra.jawe.PackageEditor;
17 import org.enhydra.jawe.xml.XMLButton;
18 import org.enhydra.jawe.misc.Version;
19
20 /**
21  * Displays about dialog for JaWE aplication.
22  */

23 public class JaWEAboutDialog extends JDialog {
24    private JButton okButton;
25    private JPanel aboutPnl;
26    private JPanel creditsPnl;
27    private JPanel infoPnl;
28    private JTabbedPane tabContainer;
29    private JToolBar buttonToolbar;
30    private JPanel txtPnl;
31    private JLabel txtJaWE;
32
33    /**
34     * CardLayout for displaying different panes on one JDialog
35     **/

36    // private CardLayout card = new CardLayout();
37
private ActionListener actionHandler = new ActionHandler();
38
39    public static void showAbout(Frame owner, String JavaDoc title, ImageIcon logo){
40       JaWEAboutDialog about =new JaWEAboutDialog(owner, title, logo);
41       about.show();
42       about=null;
43    }
44
45    private JaWEAboutDialog(Frame owner, String JavaDoc title, ImageIcon logo) {
46       super(owner, title, true);
47       createUI();
48       setResizable(false);
49       pack();
50       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
51       Dimension winsize = this.getSize();
52       setLocation(screenSize.width/2 - (winsize.width/2),
53                   screenSize.height/2 - (winsize.height/2));
54       setLocationRelativeTo(owner);
55       //createDialog();
56
//pack();
57
}
58
59    private void createUI(){
60       createButtonPane();
61       createTabbedPane();
62       getContentPane().add(tabContainer,BorderLayout.CENTER);
63       getContentPane().add(buttonToolbar,BorderLayout.SOUTH);
64       getRootPane().setDefaultButton(okButton);
65    }
66
67    private void createButtonPane(){
68       Dimension dim = getDimension(new String JavaDoc[]{"OK","Credits","About"});
69       okButton = new XMLButton("OK", "OK", dim);
70       okButton.addActionListener(actionHandler);
71       buttonToolbar = new JToolBar(JToolBar.HORIZONTAL);
72       buttonToolbar.setBorder(BorderFactory.createEmptyBorder(5,10,5,10));
73       buttonToolbar.setFloatable(false);
74       buttonToolbar.add(Box.createHorizontalGlue());
75       buttonToolbar.add(okButton);
76       buttonToolbar.add(Box.createHorizontalGlue());
77    }
78
79    private void createTabbedPane(){
80       createAboutPane();
81       createCreditsPane();
82       createInfoPane();
83       tabContainer = new JTabbedPane();
84       //TODO doraditi ovo da se cita iz property fajla
85
tabContainer.addTab("About",aboutPnl);
86       tabContainer.addTab("Credits",creditsPnl);
87       tabContainer.addTab("Info",infoPnl);
88
89    }
90
91    private void createAboutPane(){
92       JLabel aboutLabel = new JLabel(new ImageIcon(ResourceManager.
93                                                       getResource("AboutPicture")),JLabel.CENTER);
94       aboutLabel.setBorder(BorderFactory.createEtchedBorder());
95       aboutPnl = new JPanel(new BorderLayout());
96       txtPnl=new JPanel(new BorderLayout());
97       txtPnl.setFont(new Font("Serif",Font.PLAIN,14));
98       txtPnl.add(BorderLayout.NORTH,new JLabel("version: "+
99                                                   Version.getVersion(),SwingConstants.CENTER));
100       JLabel vendor=new JLabel("(c) TOGETHER - Teamlösungen",SwingConstants.CENTER);
101       vendor.setFont(new Font("SansSerif", Font.BOLD, 14));
102       txtPnl.add(BorderLayout.CENTER, vendor);
103       txtPnl.add(BorderLayout.SOUTH,
104                  new JLabel("http://jawe.objectweb.org e-mail: JaWE@objectweb.org",
105                             SwingConstants.CENTER));
106       aboutPnl.add(aboutLabel, BorderLayout.CENTER);
107       aboutPnl.add(txtPnl,BorderLayout.SOUTH);
108    }
109
110    private void createCreditsPane() {
111       creditsPnl = new JPanel(new BorderLayout());
112       JPanel contextPane = new JPanel(new GridBagLayout());
113       Insets ins = new Insets(1, 1, 1, 1);
114       txtJaWE= new JLabel("JaWE");
115       txtJaWE.setFont(new Font(txtJaWE.getFont().getFontName(),Font.BOLD,
116                                14));
117       contextPane.add(txtJaWE,
118                       new GridBagConstraints(0,0,3,1,0d,0d,GridBagConstraints.CENTER,
119                                              GridBagConstraints.NONE,new Insets(10,1,1,1),0,0));
120       contextPane.add(new JLabel("Java Workflow Editor"),
121                       new GridBagConstraints(0,1,3,1,0d,0d,GridBagConstraints.CENTER,
122                                              GridBagConstraints.NONE,ins,0,0));
123       JLabel sponsoredLabel = new JLabel("Sponsored by:");
124       sponsoredLabel.setFont(new Font(txtJaWE.getFont().getFontName(),Font.BOLD,
125                                       12));
126       contextPane.add(sponsoredLabel,
127                       new GridBagConstraints(0,2,1,1,0d,0d,GridBagConstraints.WEST,
128                                              GridBagConstraints.NONE,new Insets(15,1,1,1),0,0));
129       JLabel sponsore1logo =new JLabel(new ImageIcon(
130                                           ResourceManager.getResource("Sponsore1Logo")));
131       sponsore1logo.setBorder(BorderFactory.createEtchedBorder());
132       contextPane.add(sponsore1logo,
133                       new GridBagConstraints(0,3,1,5,0d,0d,GridBagConstraints.WEST,
134                                              GridBagConstraints.HORIZONTAL,new Insets(10,1,1,30),0,0));
135       contextPane.add(new JLabel("(c) TOGETHER - Teamlösungen"),
136                       new GridBagConstraints(1,4,2,1,0d,0d,GridBagConstraints.CENTER,
137                                              GridBagConstraints.NONE,new Insets(25,1,1,1),0,0));
138       contextPane.add(new JLabel("www.together.at"),
139                       new GridBagConstraints(1,5,2,1,0d,0d,GridBagConstraints.CENTER,
140                                              GridBagConstraints.NONE,new Insets(5,1,1,1),0,0));
141       contextPane.add(new JLabel("office@together.at"),
142                       new GridBagConstraints(1,6,2,1,0d,0d,GridBagConstraints.CENTER,
143                                              GridBagConstraints.NONE,new Insets(2,1,1,1),0,0));
144
145       JLabel sponsore2logo =new JLabel(new ImageIcon(
146                                           ResourceManager.getResource("Sponsore2Logo")));
147       sponsore2logo.setBorder(BorderFactory.createEtchedBorder());
148       contextPane.add(sponsore2logo,
149                       new GridBagConstraints(0,8,4,1,0d,0d,GridBagConstraints.WEST,
150                                              GridBagConstraints.NONE,new Insets(15,1,1,1),0,0));
151       contextPane.add(new JLabel("www.abacus.ch"),
152                       new GridBagConstraints(0,9,1,1,0d,0d,GridBagConstraints.WEST,
153                                              GridBagConstraints.NONE,new Insets(5,1,1,1),0,0));
154
155       creditsPnl.add(contextPane, BorderLayout.NORTH);
156    }
157
158    private void createInfoPane() {
159       infoPnl = new JPanel(new BorderLayout());
160       JPanel contextPane = new JPanel(new GridBagLayout());
161       Insets ins = new Insets(1, 1, 1, 1);
162       JLabel thanks = new JLabel("Many thanks to all who made this project available:");
163       thanks.setFont(new Font(thanks.getFont().getFontName(),Font.BOLD,thanks.getFont().getSize()));
164       contextPane.add(thanks,
165                       new GridBagConstraints(0,0,2,1,0d,0d,GridBagConstraints.WEST,
166                                              GridBagConstraints.HORIZONTAL,ins,0,0));
167       contextPane.add(new JLabel("jgraph - "),
168                       new GridBagConstraints(0,6,1,1,0d,0d,GridBagConstraints.EAST,
169                                              GridBagConstraints.NONE,new Insets(8,1,1,1),0,0));
170       contextPane.add(new JLabel("www.jgraph.com"),
171                       new GridBagConstraints(1,6,1,1,0d,0d,GridBagConstraints.WEST,
172                                              GridBagConstraints.NONE,new Insets(8,1,1,1),0,0));
173       contextPane.add(new JLabel("javalobby - "),
174                       new GridBagConstraints(0,7,1,1,0d,0d,GridBagConstraints.EAST,
175                                              GridBagConstraints.NONE,ins,0,0));
176       contextPane.add(new JLabel("www.gallant.com/icons.htm"),
177                       new GridBagConstraints(1,7,1,1,0d,0d,GridBagConstraints.WEST,
178                                              GridBagConstraints.NONE,ins,0,0));
179       contextPane.add(new JLabel("WFMC - "),
180                       new GridBagConstraints(0,8,1,1,0d,0d,GridBagConstraints.EAST,
181                                              GridBagConstraints.NONE,ins,0,0));
182       contextPane.add(new JLabel("www.wfmc.org"),
183                       new GridBagConstraints(1,8,1,1,0d,0d,GridBagConstraints.WEST,
184                                              GridBagConstraints.NONE,ins,0,0));
185       JTextArea txtProject = new JTextArea();
186       txtProject.setText(
187          "Many thanks to:\n\n"+
188             "Pilipovic Goran\n"+
189             "Djojic Predrag\n"+
190             "Obradovic Vladan\n"+
191             "Harald Meister\n"+
192             "Gilles Melon\n"+
193             "Pedro Morón\n"+
194             "Jakub Nadolny (IT Experts - www.ite.pl)\n"+
195             "Ivan Chen\n"+
196             "Luiz Felipe M Ghelle");
197       txtProject.setMinimumSize(new Dimension(200,100));
198       txtProject.setPreferredSize(new Dimension(250,200));
199       txtProject.setMaximumSize(new Dimension(350,350));
200       txtProject.setFont(new Font(txtJaWE.getFont().getFontName(),
201                                   txtJaWE.getFont().getStyle(),10));
202       txtProject.setBackground(Color.LIGHT_GRAY);
203       txtProject.setBorder(BorderFactory.createLoweredBevelBorder());
204       txtProject.setEditable(false);
205       //txtProject.setD
206
contextPane.add(txtProject,
207                       new GridBagConstraints(0,9,3,1,0d,0d,GridBagConstraints.CENTER,
208                                              GridBagConstraints.NONE,new Insets(15,1,1,1),0,0));
209
210
211       infoPnl.add(contextPane,BorderLayout.NORTH);
212    }
213
214    private Dimension getDimension(String JavaDoc[] s){
215       String JavaDoc[] labels = s;
216       int longest=0;
217       int w=0;
218       for (int i=0; i<labels.length; i++) {
219          try {
220             w=getFontMetrics(getFont()).stringWidth(labels[i]);
221             if (w>longest)
222                longest=w;
223          } catch(Exception JavaDoc e) {}
224       }
225       w=longest+22;
226       int h = getFontMetrics(getFont()).getHeight()+2;
227       Dimension dim = new Dimension(w,h);
228       return dim;
229    }
230
231    // Close on escape
232
protected JRootPane createRootPane() {
233       KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
234       JRootPane rootPane = new JRootPane();
235       rootPane.registerKeyboardAction(new ActionListener() {
236                public void actionPerformed(ActionEvent actionEvent) {
237                   setVisible(false);
238                }
239             }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
240       return rootPane;
241    }
242
243    private class ActionHandler implements ActionListener {
244       public void actionPerformed(ActionEvent e) {
245          if (e.getSource() == okButton) {
246             dispose();
247          }
248          /*
249           else{
250           if (e.getSource() == creditsButton) {
251           if (about){
252           card.show(mainPnl, "credits");
253           about=false;
254           creditsButton.setIcon(new ImageIcon(ResourceManager.getResource("HelpAboutImage")));
255           creditsButton.setText("About");
256           } else{
257           card.show(mainPnl, "about");
258           about=true;
259           creditsButton.setIcon(new ImageIcon(ResourceManager.getResource("CreditsImage")));
260           creditsButton.setText("Credits");
261           }
262           }
263           }
264           */

265       }
266    }
267 }
268
269 /** End of PEAboutDialog.java */
270
271
Popular Tags