OSDN Git Service

toString実装
[coroid/inqubus.git] / frontend / src / saccubus / MainFrame_AboutBox.java
index 9d8ab8c..c0f697c 100644 (file)
@@ -8,7 +8,6 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -22,8 +21,6 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 import javax.swing.SwingUtilities;
 
-
-
 /**
  * <p>
  * タイトル: さきゅばす
@@ -45,54 +42,41 @@ import javax.swing.SwingUtilities;
  * @version 1.0
  */
 public class MainFrame_AboutBox extends JDialog implements ActionListener {
-       /**
-        *
-        */
-       private static final long serialVersionUID = -4256413309312729840L;
+
+    private static final String VERSION = "いんきゅばす 2.0.0";
+    private static final long serialVersionUID = -4256413309312729840L;
     private static final Logger logger = Logger.getLogger(MainFrame_AboutBox.class.getName());
     private static final String LINE_FEED = System.getProperty("line.separator");
+    private final JButton okButton = new JButton();
 
-       private static final String version = "ver1.22r(2008/04/27)";
-
-       private static final String product =
-            "本プログラムは「さきゅばす」を改変したものであり, \n" + "オリジナルの著作権は以下の通りです.\n\n" +
-               "さきゅばす\n"+
-               version + "\n\n"+
-               "Copyright (C) 2008 Saccubus Developers Team\n"+
-               "              2007-2008 PSI\n\n"+
-               "ニコニコ動画の動画をコメントつきで保存";
+    public MainFrame_AboutBox(Frame parent) {
+        super(parent);
+        try {
+            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+            jbInit();
+        } catch (Exception exception) {
+            logger.log(Level.SEVERE, null, exception);
+        }
+    }
 
-       private final JButton okButton = new JButton();
+    public MainFrame_AboutBox() {
+        this(null);
+    }
 
-       public MainFrame_AboutBox(Frame parent) {
-               super(parent);
-               try {
-                       setDefaultCloseOperation(DISPOSE_ON_CLOSE);
-                       jbInit();
-               } catch (Exception exception) {
-            logger.log(Level.SEVERE, null, exception);
-               }
-       }
-
-       public MainFrame_AboutBox() {
-               this(null);
-       }
-
-       /**
-        * コンポーネントの初期化。
-        *
-        * @throws java.lang.Exception
-        */
-       private void jbInit() throws Exception {
+    /**
+     * コンポーネントの初期化。
+     *
+     * @throws java.lang.Exception
+     */
+    private void jbInit() {
         final JPanel basePanel = new JPanel();
 
         final JLabel imageLabel = new JLabel();
         final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
-               imageLabel.setIcon(icon);
+        imageLabel.setIcon(icon);
 
-        final JTextArea productField = new JTextArea(product);
-               productField.setBackground(basePanel.getBackground());
-               productField.setEditable(false);
+        final JTextArea productField = createProductField();
+        productField.setBackground(basePanel.getBackground());
 
         final JScrollPane licensePane = createLicensePane();
 
@@ -100,7 +84,7 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener {
         okButton.addActionListener(this);
 
 
-        basePanel.setPreferredSize(new Dimension(500, 500));
+        basePanel.setPreferredSize(new Dimension(500, 600));
         GroupLayout gl = new GroupLayout(basePanel);
         basePanel.setLayout(gl);
 
@@ -118,49 +102,66 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener {
                 .addComponent(licensePane)
                 .addComponent(okButton));
 
-               getContentPane().add(basePanel, null);
+        getContentPane().add(basePanel, null);
 
-               setTitle("バージョン情報");
+        setTitle("バージョン情報");
         setResizable(true);
-       }
+    }
 
-    private JScrollPane createLicensePane() throws IOException {
-        final JTextArea licenseField = new JTextArea();
-        InputStream res = null;
-        try {
-            res = saccubus.MainFrame_AboutBox.class.getResourceAsStream("LICENSE.txt");
-            final BufferedReader reader = new BufferedReader(new InputStreamReader(res, "UTF-8"));
+    private JTextArea createProductField() {
+        final JTextArea area = new JTextArea();
+        area.append(VERSION);
+        area.append(LINE_FEED);
+        area.append(LINE_FEED);
 
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
+                        "saccubus_description.txt"), "UTF-8"))) {
+            String line;
+            while ((line = reader.readLine()) != null) {
+                area.append(line);
+                area.append(LINE_FEED);
+            }
+        } catch (IOException ex) {
+            logger.log(Level.SEVERE, null, ex);
+        }
+
+        area.setEditable(false);
+        return area;
+    }
+
+    private JScrollPane createLicensePane() {
+        final JTextArea licenseField = new JTextArea();
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
+                        "LICENSE.txt"), "UTF-8"))) {
             String line;
             while ((line = reader.readLine()) != null) {
                 licenseField.append(line);
                 licenseField.append(LINE_FEED);
             }
-        } finally {
-            if (res != null) {
-                res.available();
-            }
+        } catch (IOException ex) {
+            logger.log(Level.SEVERE, null, ex);
         }
+
         licenseField.setCaretPosition(0);
         licenseField.setEditable(false);
         final JScrollPane licensePane = new JScrollPane(licenseField);
         return licensePane;
     }
 
-       /**
-        * ボタンイベントでダイアログを閉じる
-        *
-        * @param actionEvent
-        *            ActionEvent
-        */
+    /**
+     * ボタンイベントでダイアログを閉じる
+     *
+     * @param actionEvent
+     *            ActionEvent
+     */
     @Override
-       public void actionPerformed(ActionEvent actionEvent) {
-               if (actionEvent.getSource() == okButton) {
-                       dispose();
-               }
-       }
+    public void actionPerformed(ActionEvent actionEvent) {
+        if (actionEvent.getSource() == okButton) {
+            dispose();
+        }
+    }
 
-    public static void main(String[] args){
+    public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable() {
 
             @Override