KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > awt > viewer > PreviewDialogAboutBox


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: PreviewDialogAboutBox.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.awt.viewer;
21
22 //Java
23
import java.awt.AWTEvent JavaDoc;
24 import java.awt.BorderLayout JavaDoc;
25 import java.awt.Dialog JavaDoc;
26 import java.awt.FlowLayout JavaDoc;
27 import java.awt.Frame JavaDoc;
28 import java.awt.GridLayout JavaDoc;
29
30 import javax.swing.ImageIcon JavaDoc;
31 import javax.swing.JButton JavaDoc;
32 import javax.swing.JLabel JavaDoc;
33 import javax.swing.JPanel JavaDoc;
34 import javax.swing.border.EmptyBorder JavaDoc;
35 import java.awt.event.ActionListener JavaDoc;
36 import java.awt.event.WindowEvent JavaDoc;
37 import java.awt.event.ActionEvent JavaDoc;
38
39 //FOP
40
import org.apache.fop.Version;
41
42 /**
43  * AWT Viewer's "About" dialog.
44  * Originally contributed by:
45  * Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
46  * Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
47  * Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
48  */

49 public class PreviewDialogAboutBox extends Dialog JavaDoc implements ActionListener JavaDoc {
50     private JButton JavaDoc okButton;
51
52     /**
53      * Creates modal "About" dialog, attached to a given parent frame.
54      * @param parent parent frame
55      * @param translator Translator for localization
56      */

57     public PreviewDialogAboutBox(Frame JavaDoc parent, Translator translator) {
58         super(parent, true);
59         enableEvents(AWTEvent.WINDOW_EVENT_MASK);
60         setTitle(translator.getString("About.Title"));
61         setResizable(false);
62         JPanel JavaDoc panel1 = new JPanel JavaDoc();
63         JPanel JavaDoc panel2 = new JPanel JavaDoc();
64         JPanel JavaDoc insetsPanel1 = new JPanel JavaDoc();
65         JPanel JavaDoc insetsPanel2 = new JPanel JavaDoc();
66         JPanel JavaDoc insetsPanel3 = new JPanel JavaDoc();
67         okButton = new JButton JavaDoc();
68         JLabel JavaDoc imageControl1 = new JLabel JavaDoc();
69         imageControl1.setIcon(new ImageIcon JavaDoc(getClass().getResource("images/fop.gif")));
70         JLabel JavaDoc label1 = new JLabel JavaDoc(translator.getString("About.Product"));
71         JLabel JavaDoc label2 = new JLabel JavaDoc(translator.getString("About.Version")
72                                             + " " + Version.getVersion());
73         JLabel JavaDoc label3 = new JLabel JavaDoc(translator.getString("About.Copyright"));
74         panel1.setLayout(new BorderLayout JavaDoc());
75         panel2.setLayout(new BorderLayout JavaDoc());
76         insetsPanel1.setLayout(new FlowLayout JavaDoc());
77         insetsPanel2.setLayout(new FlowLayout JavaDoc());
78         insetsPanel2.setBorder(new EmptyBorder JavaDoc(10, 10, 10, 10));
79         insetsPanel3.setLayout(new GridLayout JavaDoc(3, 1));
80         insetsPanel3.setBorder(new EmptyBorder JavaDoc(10, 10, 10, 10));
81         okButton.setText(translator.getString("Button.Ok"));
82         okButton.addActionListener(this);
83         insetsPanel2.add(imageControl1, null);
84         panel2.add(insetsPanel2, BorderLayout.WEST);
85         insetsPanel3.add(label1);
86         insetsPanel3.add(label2);
87         insetsPanel3.add(label3);
88         panel2.add(insetsPanel3, BorderLayout.CENTER);
89         insetsPanel1.add(okButton);
90         panel1.add(insetsPanel1, BorderLayout.SOUTH);
91         panel1.add(panel2, BorderLayout.NORTH);
92         add(panel1);
93         pack();
94     }
95
96     /**
97      * @see java.awt.Window#processWindowEvent(WindowEvent)
98      */

99     protected void processWindowEvent(WindowEvent JavaDoc e) {
100         if (e.getID() == WindowEvent.WINDOW_CLOSING) {
101             cancel();
102         }
103         super.processWindowEvent(e);
104     }
105
106     private void cancel() {
107         dispose();
108     }
109
110     /**
111      * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
112      */

113     public void actionPerformed(ActionEvent JavaDoc e) {
114         if (e.getSource() == okButton) {
115             cancel();
116         }
117     }
118 }
119
120
Popular Tags