OSDN Git Service

fd69a253024e64f057e2ee2eb8d72c0bd998297f
[coroid/inqubus.git] / frontend / src / saccubus / MainFrame_AboutBox.java
1 package saccubus;
2
3 import static javax.swing.WindowConstants.*;
4
5 import java.awt.Dimension;
6 import java.awt.Frame;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
9 import java.io.BufferedReader;
10 import java.io.IOException;
11 import java.io.InputStreamReader;
12 import java.util.logging.Level;
13 import java.util.logging.Logger;
14 import javax.swing.GroupLayout;
15 import javax.swing.ImageIcon;
16 import javax.swing.JButton;
17 import javax.swing.JDialog;
18 import javax.swing.JLabel;
19 import javax.swing.JPanel;
20 import javax.swing.JScrollPane;
21 import javax.swing.JTextArea;
22 import javax.swing.SwingUtilities;
23
24
25
26 /**
27  * <p>
28  * タイトル: さきゅばす
29  * </p>
30  *
31  * <p>
32  * 説明: ニコニコ動画の動画をコメントつきで保存
33  * </p>
34  *
35  * <p>
36  * 著作権: Copyright (c) 2007 PSI
37  * </p>
38  *
39  * <p>
40  * 会社名:
41  * </p>
42  *
43  * @author 未入力
44  * @version 1.0
45  */
46 public class MainFrame_AboutBox extends JDialog implements ActionListener {
47         /**
48          *
49          */
50         private static final long serialVersionUID = -4256413309312729840L;
51     private static final Logger logger = Logger.getLogger(MainFrame_AboutBox.class.getName());
52     private static final String LINE_FEED = System.getProperty("line.separator");
53
54         private static final String version = "ver1.22r(2008/04/27)";
55
56         private static final String product =
57             "本プログラムは「さきゅばす」を改変したものであり, \n" + "オリジナルの著作権は以下の通りです.\n\n" +
58                 "さきゅばす\n"+
59                 version + "\n\n"+
60                 "Copyright (C) 2008 Saccubus Developers Team\n"+
61                 "              2007-2008 PSI\n\n"+
62                 "ニコニコ動画の動画をコメントつきで保存";
63
64         private final JButton okButton = new JButton();
65
66         public MainFrame_AboutBox(Frame parent) {
67                 super(parent);
68                 try {
69                         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
70                         jbInit();
71                 } catch (Exception exception) {
72             logger.log(Level.SEVERE, null, exception);
73                 }
74         }
75
76         public MainFrame_AboutBox() {
77                 this(null);
78         }
79
80         /**
81          * コンポーネントの初期化。
82          *
83          * @throws java.lang.Exception
84          */
85         private void jbInit() {
86         final JPanel basePanel = new JPanel();
87
88         final JLabel imageLabel = new JLabel();
89         final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
90                 imageLabel.setIcon(icon);
91
92         final JTextArea productField = new JTextArea(product);
93                 productField.setBackground(basePanel.getBackground());
94                 productField.setEditable(false);
95
96         final JScrollPane licensePane = createLicensePane();
97
98         okButton.setText("OK");
99         okButton.addActionListener(this);
100
101
102         basePanel.setPreferredSize(new Dimension(500, 500));
103         GroupLayout gl = new GroupLayout(basePanel);
104         basePanel.setLayout(gl);
105
106         gl.setHorizontalGroup(gl.createParallelGroup(GroupLayout.Alignment.CENTER)
107                 .addGroup(gl.createSequentialGroup()
108                     .addGap(15).addComponent(imageLabel).addGap(30).addComponent(productField).addGap(30))
109                 .addComponent(licensePane)
110                 .addComponent(okButton));
111
112         gl.setVerticalGroup(gl.createSequentialGroup()
113                 .addGap(15)
114                 .addGroup(gl.createParallelGroup()
115                     .addComponent(imageLabel).addComponent(productField))
116                 .addGap(15)
117                 .addComponent(licensePane)
118                 .addComponent(okButton));
119
120                 getContentPane().add(basePanel, null);
121
122                 setTitle("バージョン情報");
123         setResizable(true);
124         }
125
126     private JScrollPane createLicensePane() {
127         final JTextArea licenseField = new JTextArea();
128         try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
129                         "LICENSE.txt"), "UTF-8"))) {
130             String line;
131             while ((line = reader.readLine()) != null) {
132                 licenseField.append(line);
133                 licenseField.append(LINE_FEED);
134             }
135         }catch(IOException ex){
136             logger.log(Level.SEVERE, null, ex);
137         }
138
139         licenseField.setCaretPosition(0);
140         licenseField.setEditable(false);
141         final JScrollPane licensePane = new JScrollPane(licenseField);
142         return licensePane;
143     }
144
145         /**
146          * ボタンイベントでダイアログを閉じる
147          *
148          * @param actionEvent
149          *            ActionEvent
150          */
151     @Override
152         public void actionPerformed(ActionEvent actionEvent) {
153                 if (actionEvent.getSource() == okButton) {
154                         dispose();
155                 }
156         }
157
158     public static void main(String[] args){
159         SwingUtilities.invokeLater(new Runnable() {
160
161             @Override
162             public void run() {
163                 MainFrame_AboutBox frame = new MainFrame_AboutBox();
164                 frame.pack();
165                 frame.setVisible(true);
166             }
167         });
168     }
169 }