001 /*
002 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: AboutDialog.java,v 9fe6e50a4648 2008/05/23 10:08:31 maxberger $ */
018
019 package net.sourceforge.jeuclid.app.mathviewer;
020
021 import java.awt.BorderLayout;
022 import java.awt.Font;
023 import java.awt.Frame;
024 import java.awt.event.KeyAdapter;
025 import java.awt.event.KeyEvent;
026
027 import javax.swing.ImageIcon;
028 import javax.swing.JDialog;
029 import javax.swing.JLabel;
030 import javax.swing.JOptionPane;
031 import javax.swing.JPanel;
032 import javax.swing.SwingConstants;
033
034 import net.sourceforge.jeuclid.LayoutContext;
035
036 /**
037 * About Dialog for MathViewer.
038 *
039 * @version $Revision: 9fe6e50a4648 $
040 */
041 public final class AboutDialog extends JDialog {
042
043 private static final int LARGE_FONT = 14;
044
045 private static final int SMALL_FONT = 12;
046
047 private static final String ABOUT_FONT = "SansSerif";
048
049 private static final long serialVersionUID = 1L;
050
051 private JPanel jContentPane;
052
053 private JLabel iconLabel;
054
055 private JLabel jeuclidLabel;
056
057 private JLabel wwwLabel;
058
059 /**
060 * @param owner
061 * Owner for this frame.
062 */
063 public AboutDialog(final Frame owner) {
064 super(owner);
065 this.initialize();
066 }
067
068 /**
069 * This method initializes this
070 *
071 * @return void
072 */
073 private void initialize() {
074 this.setModal(true);
075 this.setResizable(false);
076 this.setContentPane(this.getJContentPane());
077 this.setTitle(Messages.getString("MathViewer.aboutWindowTitle")); //$NON-NLS-1$
078 this.addKeyListener(new KeyAdapter() {
079 @Override
080 public void keyPressed(final KeyEvent e) {
081 if (e.getKeyCode() == KeyEvent.VK_V && e.isAltDown()) {
082 JOptionPane.showMessageDialog(AboutDialog.this,
083 "Version: "
084 + LayoutContext.class.getPackage()
085 .getImplementationVersion());
086 }
087 }
088 });
089 }
090
091 /**
092 * This method initializes jContentPane
093 *
094 * @return javax.swing.JPanel
095 */
096 private JPanel getJContentPane() {
097 if (this.jContentPane == null) {
098 this.wwwLabel = new JLabel();
099 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 }