001: package org.jsqltool.gui;
002:
003: import java.awt.*;
004: import java.awt.event.*;
005: import javax.swing.*;
006: import javax.swing.border.*;
007: import java.util.ArrayList;
008: import org.jsqltool.conn.gui.*;
009: import org.jsqltool.gui.tablepanel.*;
010: import org.jsqltool.utils.Options;
011: import org.jsqltool.utils.ImageLoader;
012:
013: /**
014: * <p>Title: JSqlTool Project</p>
015: * <p>Description: About Window.
016: * </p>
017: * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
018: *
019: * <p> This file is part of JSqlTool project.
020: * This library is free software; you can redistribute it and/or
021: * modify it under the terms of the (LGPL) Lesser General Public
022: * License as published by the Free Software Foundation;
023: *
024: * GNU LESSER GENERAL PUBLIC LICENSE
025: * Version 2.1, February 1999
026: *
027: * This library is distributed in the hope that it will be useful,
028: * but WITHOUT ANY WARRANTY; without even the implied warranty of
029: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
030: * Library General Public License for more details.
031: *
032: * You should have received a copy of the GNU Library General Public
033: * License along with this library; if not, write to the Free
034: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
035: *
036: * The author may be contacted at:
037: * maurocarniel@tin.it</p>
038: *
039: * @author Mauro Carniel
040: * @version 1.0
041: */
042: public class AboutBox extends JDialog implements ActionListener {
043:
044: JPanel panel1 = new JPanel();
045: JPanel panel2 = new JPanel();
046: JPanel insetsPanel1 = new JPanel();
047: JPanel insetsPanel3 = new JPanel();
048: JButton button1 = new JButton();
049: JLabel label1 = new JLabel();
050: JLabel label2 = new JLabel();
051: JLabel label3 = new JLabel();
052: ImageIcon image1 = new ImageIcon();
053: BorderLayout borderLayout1 = new BorderLayout();
054: JScrollPane scrollPane = new JScrollPane();
055: GridBagLayout gridBagLayout1 = new GridBagLayout();
056: JTextArea other = new JTextArea();
057: GridBagLayout gridBagLayout2 = new GridBagLayout();
058: JButton iconButton = new JButton(ImageLoader.getInstance().getIcon(
059: "about.gif"));
060:
061: public AboutBox(MainFrame parent) {
062: super (parent);
063: enableEvents(AWTEvent.WINDOW_EVENT_MASK);
064: try {
065: jbInit();
066: init();
067: setSize(400, 400);
068: button1.requestFocus();
069: } catch (Exception e) {
070: e.printStackTrace();
071: }
072: }
073:
074: private void init() {
075: other.append(Options.getInstance().getResource("plugins")
076: + ":\n");
077: /*
078: other.append("\nJCalendar\n");
079: other.append("© Kai Toedter 1999-2002\n");
080: other.append("Version 1.1.4\n");
081: other.append("07/17/02\n");
082: */
083: ArrayList panels = TableDetailPanel.getSortPanels();
084: TablePlugin panel = null;
085: for (int i = 0; i < panels.size(); i++) {
086: panel = (TablePlugin) panels.get(i);
087: other.append("\n" + panel.getName() + "\n");
088: other.append(Options.getInstance().getResource("version")
089: + " " + panel.getVersion() + "\n");
090: if (panel.getAuthor() != null
091: && !panel.getAuthor().equals(""))
092: other.append(Options.getInstance()
093: .getResource("author")
094: + " " + panel.getAuthor() + "\n");
095: }
096: other.setCaretPosition(0);
097: }
098:
099: //Component initialization
100: private void jbInit() throws Exception {
101: image1 = ImageLoader.getInstance().getIcon("logo.gif");
102: this .setTitle(Options.getInstance().getResource("about"));
103: panel1.setLayout(borderLayout1);
104: panel2.setLayout(gridBagLayout1);
105: label1.setFont(new java.awt.Font("Dialog", 1, 11));
106: label1.setText("JSQLTool");
107: label2.setText(Options.getInstance().getResource("release")
108: + " 1.1");
109: label3.setText("Copyright (C) 2006 Mauro Carniel");
110: insetsPanel3.setLayout(gridBagLayout2);
111: insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 60,
112: 10, 10));
113: button1.setMnemonic(Options.getInstance().getResource(
114: "okbutton.mnemonic").charAt(0));
115: button1.setText(Options.getInstance().getResource(
116: "okbutton.text"));
117: button1.addActionListener(this );
118: other.setBackground(SystemColor.activeCaptionBorder);
119: other.setEditable(false);
120: other.setText("");
121: iconButton.setBorder(null);
122: this .getContentPane().add(panel1, null);
123: insetsPanel3.add(label1, new GridBagConstraints(1, 0, 1, 1,
124: 1.0, 0.0, GridBagConstraints.WEST,
125: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
126: insetsPanel3.add(label2, new GridBagConstraints(1, 1, 1, 1,
127: 0.0, 0.0, GridBagConstraints.WEST,
128: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
129: insetsPanel3.add(label3, new GridBagConstraints(1, 2, 1, 1,
130: 0.0, 0.0, GridBagConstraints.WEST,
131: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
132: insetsPanel3.add(iconButton, new GridBagConstraints(0, 0, 1, 3,
133: 0.0, 0.0, GridBagConstraints.NORTHWEST,
134: GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
135: panel2.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0,
136: 1.0, GridBagConstraints.CENTER,
137: GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0,
138: 0));
139: panel2.add(insetsPanel3, new GridBagConstraints(0, 0, 1, 1,
140: 1.0, 0.0, GridBagConstraints.CENTER,
141: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
142: insetsPanel1.add(button1, null);
143: panel1.add(insetsPanel1, BorderLayout.SOUTH);
144: panel1.add(panel2, BorderLayout.CENTER);
145: scrollPane.getViewport().add(other, null);
146: setResizable(true);
147: }
148:
149: //Overridden so we can exit when window is closed
150: protected void processWindowEvent(WindowEvent e) {
151: if (e.getID() == WindowEvent.WINDOW_CLOSING) {
152: cancel();
153: }
154: super .processWindowEvent(e);
155: }
156:
157: //Close the dialog
158: void cancel() {
159: dispose();
160: }
161:
162: //Close the dialog on a button event
163: public void actionPerformed(ActionEvent e) {
164: if (e.getSource() == button1) {
165: cancel();
166: }
167: }
168: }
|