3 import static javax.swing.WindowConstants.*;
5 import java.awt.Dimension;
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;
30 * 説明: ニコニコ動画の動画をコメントつきで保存
34 * 著作権: Copyright (c) 2007 PSI
44 public class MainFrame_AboutBox extends JDialog implements ActionListener {
46 private static final String VERSION = "いんきゅばす 2.0.0";
47 private static final long serialVersionUID = -4256413309312729840L;
48 private static final Logger logger = Logger.getLogger(MainFrame_AboutBox.class.getName());
49 private static final String LINE_FEED = System.getProperty("line.separator");
50 private final JButton okButton = new JButton();
52 public MainFrame_AboutBox(Frame parent) {
55 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
57 } catch (Exception exception) {
58 logger.log(Level.SEVERE, null, exception);
62 public MainFrame_AboutBox() {
69 * @throws java.lang.Exception
71 private void jbInit() {
72 final JPanel basePanel = new JPanel();
74 final JLabel imageLabel = new JLabel();
75 final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
76 imageLabel.setIcon(icon);
78 final JTextArea productField = createProductField();
79 productField.setBackground(basePanel.getBackground());
81 final JScrollPane licensePane = createLicensePane();
83 okButton.setText("OK");
84 okButton.addActionListener(this);
87 basePanel.setPreferredSize(new Dimension(500, 600));
88 GroupLayout gl = new GroupLayout(basePanel);
89 basePanel.setLayout(gl);
91 gl.setHorizontalGroup(gl.createParallelGroup(GroupLayout.Alignment.CENTER)
92 .addGroup(gl.createSequentialGroup()
93 .addGap(15).addComponent(imageLabel).addGap(30).addComponent(productField).addGap(30))
94 .addComponent(licensePane)
95 .addComponent(okButton));
97 gl.setVerticalGroup(gl.createSequentialGroup()
99 .addGroup(gl.createParallelGroup()
100 .addComponent(imageLabel).addComponent(productField))
102 .addComponent(licensePane)
103 .addComponent(okButton));
105 getContentPane().add(basePanel, null);
111 private JTextArea createProductField() {
112 final JTextArea area = new JTextArea();
113 area.append(VERSION);
114 area.append(LINE_FEED);
115 area.append(LINE_FEED);
117 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
118 "saccubus_description.txt"), "UTF-8"))) {
120 while ((line = reader.readLine()) != null) {
122 area.append(LINE_FEED);
124 } catch (IOException ex) {
125 logger.log(Level.SEVERE, null, ex);
128 area.setEditable(false);
132 private JScrollPane createLicensePane() {
133 final JTextArea licenseField = new JTextArea();
134 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
135 "LICENSE.txt"), "UTF-8"))) {
137 while ((line = reader.readLine()) != null) {
138 licenseField.append(line);
139 licenseField.append(LINE_FEED);
141 } catch (IOException ex) {
142 logger.log(Level.SEVERE, null, ex);
145 licenseField.setCaretPosition(0);
146 licenseField.setEditable(false);
147 final JScrollPane licensePane = new JScrollPane(licenseField);
158 public void actionPerformed(ActionEvent actionEvent) {
159 if (actionEvent.getSource() == okButton) {
164 public static void main(String[] args) {
165 SwingUtilities.invokeLater(new Runnable() {
169 MainFrame_AboutBox frame = new MainFrame_AboutBox();
171 frame.setVisible(true);