View Javadoc

1   /*
2    * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* $Id: AboutDialog.java,v 9fe6e50a4648 2008/05/23 10:08:31 maxberger $ */
18  
19  package net.sourceforge.jeuclid.app.mathviewer;
20  
21  import java.awt.BorderLayout;
22  import java.awt.Font;
23  import java.awt.Frame;
24  import java.awt.event.KeyAdapter;
25  import java.awt.event.KeyEvent;
26  
27  import javax.swing.ImageIcon;
28  import javax.swing.JDialog;
29  import javax.swing.JLabel;
30  import javax.swing.JOptionPane;
31  import javax.swing.JPanel;
32  import javax.swing.SwingConstants;
33  
34  import net.sourceforge.jeuclid.LayoutContext;
35  
36  /**
37   * About Dialog for MathViewer.
38   * 
39   * @version $Revision: 9fe6e50a4648 $
40   */
41  public final class AboutDialog extends JDialog {
42  
43      private static final int LARGE_FONT = 14;
44  
45      private static final int SMALL_FONT = 12;
46  
47      private static final String ABOUT_FONT = "SansSerif";
48  
49      private static final long serialVersionUID = 1L;
50  
51      private JPanel jContentPane;
52  
53      private JLabel iconLabel;
54  
55      private JLabel jeuclidLabel;
56  
57      private JLabel wwwLabel;
58  
59      /**
60       * @param owner
61       *            Owner for this frame.
62       */
63      public AboutDialog(final Frame owner) {
64          super(owner);
65          this.initialize();
66      }
67  
68      /**
69       * This method initializes this
70       * 
71       * @return void
72       */
73      private void initialize() {
74          this.setModal(true);
75          this.setResizable(false);
76          this.setContentPane(this.getJContentPane());
77          this.setTitle(Messages.getString("MathViewer.aboutWindowTitle")); //$NON-NLS-1$
78          this.addKeyListener(new KeyAdapter() {
79              @Override
80              public void keyPressed(final KeyEvent e) {
81                  if (e.getKeyCode() == KeyEvent.VK_V && e.isAltDown()) {
82                      JOptionPane.showMessageDialog(AboutDialog.this,
83                              "Version: "
84                                      + LayoutContext.class.getPackage()
85                                              .getImplementationVersion());
86                  }
87              }
88          });
89      }
90  
91      /**
92       * This method initializes jContentPane
93       * 
94       * @return javax.swing.JPanel
95       */
96      private JPanel getJContentPane() {
97          if (this.jContentPane == null) {
98              this.wwwLabel = new JLabel();
99              this.wwwLabel.setText(" http://jeuclid.sourceforge.net ");
100             this.wwwLabel.setFont(new Font(AboutDialog.ABOUT_FONT,
101                     Font.PLAIN, AboutDialog.SMALL_FONT));
102             this.wwwLabel.setHorizontalAlignment(SwingConstants.CENTER);
103             this.jeuclidLabel = new JLabel();
104             this.jeuclidLabel.setText("JEuclid MathViewer");
105             this.jeuclidLabel.setHorizontalAlignment(SwingConstants.CENTER);
106             this.jeuclidLabel.setFont(new Font(AboutDialog.ABOUT_FONT,
107                     Font.BOLD, AboutDialog.LARGE_FONT));
108             this.iconLabel = new JLabel();
109             this.iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
110             this.iconLabel.setIcon(new ImageIcon(this.getClass().getResource(
111                     "/icons/jeuclid_128x128.png")));
112             this.jContentPane = new JPanel();
113             this.jContentPane.setLayout(new BorderLayout());
114             this.jContentPane.add(this.iconLabel, BorderLayout.NORTH);
115             this.jContentPane.add(this.jeuclidLabel, BorderLayout.CENTER);
116             this.jContentPane.add(this.wwwLabel, BorderLayout.SOUTH);
117         }
118         return this.jContentPane;
119     }
120 
121 }