001: /*
002: * $Id: JGraphpadAboutDialog.java,v 1.4 2007/05/24 13:12:26 gaudenz Exp $
003: * Copyright (c) 2001-2005, Gaudenz Alder
004: *
005: * All rights reserved.
006: *
007: * See LICENSE file for license details. If you are unable to locate
008: * this file please contact info (at) jgraph (dot) com.
009: */
010: package com.jgraph.pad.dialog;
011:
012: import java.awt.BorderLayout;
013: import java.awt.event.ActionEvent;
014: import java.awt.event.ActionListener;
015: import java.awt.event.KeyEvent;
016:
017: import javax.swing.BorderFactory;
018: import javax.swing.ImageIcon;
019: import javax.swing.JButton;
020: import javax.swing.JComponent;
021: import javax.swing.JDialog;
022: import javax.swing.JPanel;
023: import javax.swing.JRootPane;
024: import javax.swing.JTabbedPane;
025: import javax.swing.JTextArea;
026: import javax.swing.KeyStroke;
027:
028: import org.jgraph.JGraph;
029:
030: import com.jgraph.JGraphpad;
031: import com.jgraph.editor.JGraphEditorResources;
032:
033: /**
034: * About dialog for the JGraphpad application.
035: */
036: public class JGraphpadAboutDialog extends JGraphpadDialog {
037:
038: /**
039: * Defines the text used in the copyright tab.
040: */
041: protected static final String COPYRIGHT = "JGraphpad Pro\n"
042: + "Copyright (C) 2001-2005 by Gaudenz Alder\n"
043: + JGraphpad.VERSION + "\n" + JGraph.VERSION;
044:
045: /**
046: * Defines the text used in the credits tab.
047: */
048: protected static final String CREDITS = "Third-party libraries used:\n"
049: + "Batik\n"
050: + "BeanShell\n"
051: + "EPSGraphics\n"
052: + "iText\n"
053: + "L2FProd\n" + "Looks\n";
054:
055: /**
056: * Constructs a new about dialog using the specified icon.
057: *
058: * @param icon
059: * The icon to display in the dialog header.
060: */
061: public JGraphpadAboutDialog(ImageIcon icon) {
062: super ("About JGraphpad Pro",
063: "For more information visit http://www.jgraph.com/",
064: icon);
065: setSize(640, 480);
066:
067: // Adds OK button to close window
068: JButton okButton = new JButton(JGraphEditorResources
069: .getString("OK"));
070: addButtons(new JButton[] { okButton });
071: okButton.addActionListener(new ActionListener() {
072: public void actionPerformed(ActionEvent e) {
073: setVisible(false);
074: }
075: });
076:
077: // Sets default button for enter key
078: getRootPane().setDefaultButton(okButton);
079: }
080:
081: /**
082: * Overrides {@link JGraphpadDialog#createContent()} to provide the actual
083: * content of the dialog.
084: *
085: * @return Returns the content of the about dialog.
086: */
087: protected JComponent createContent() {
088: JPanel panel = new JPanel();
089: panel.setLayout(new BorderLayout());
090: panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
091: JTabbedPane tabbedPane = new JTabbedPane();
092:
093: // Adds the copyright tab
094: JTextArea copyright = new JTextArea();
095: copyright.setOpaque(false);
096: copyright
097: .setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
098: copyright.setText(COPYRIGHT);
099: tabbedPane.addTab(JGraphEditorResources.getString("Copyright"),
100: copyright);
101:
102: // Adds the credits tab
103: JTextArea credits = new JTextArea();
104: credits.setOpaque(false);
105: credits.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
106: credits.setText(CREDITS);
107: tabbedPane.addTab(JGraphEditorResources.getString("Credits"),
108: credits);
109:
110: panel.add(tabbedPane, BorderLayout.CENTER);
111: return panel;
112: }
113:
114: /**
115: * Overrides {@link JDialog#createRootPane()} to return a root pane that
116: * hides the window when the user presses the ESCAPE key.O
117: */
118: protected JRootPane createRootPane() {
119: KeyStroke stroke = KeyStroke
120: .getKeyStroke(KeyEvent.VK_ESCAPE, 0);
121: JRootPane rootPane = new JRootPane();
122: rootPane.registerKeyboardAction(new ActionListener() {
123: public void actionPerformed(ActionEvent actionEvent) {
124: setVisible(false);
125: }
126: }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
127: return rootPane;
128: }
129:
130: }
|