4 import static javax.swing.WindowConstants.*;
6 import java.awt.Dimension;
8 import java.awt.event.ActionEvent;
9 import java.awt.event.ActionListener;
10 import java.io.BufferedReader;
11 import java.io.IOException;
12 import java.io.InputStreamReader;
13 import java.util.logging.Level;
14 import java.util.logging.Logger;
15 import javax.swing.BorderFactory;
16 import javax.swing.GroupLayout;
17 import javax.swing.ImageIcon;
18 import javax.swing.JButton;
19 import javax.swing.JDialog;
20 import javax.swing.JLabel;
21 import javax.swing.JPanel;
22 import javax.swing.JScrollPane;
23 import javax.swing.JTextArea;
24 import javax.swing.SwingUtilities;
32 * 説明: ニコニコ動画の動画をコメントつきで保存
36 * 著作権: Copyright (c) 2007 PSI
46 public class MainFrame_AboutBox extends JDialog implements ActionListener {
48 private static final String VERSION = "いんきゅばす 2.0.0";
49 private static final long serialVersionUID = -4256413309312729840L;
50 private static final Logger logger = Logger.getLogger(MainFrame_AboutBox.class.getName());
51 private static final String LINE_FEED = System.getProperty("line.separator");
52 private final JButton okButton = new JButton();
54 public MainFrame_AboutBox(Frame parent) {
57 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
59 } catch (Exception exception) {
60 logger.log(Level.SEVERE, null, exception);
64 public MainFrame_AboutBox() {
71 * @throws java.lang.Exception
73 private void jbInit() {
74 final JPanel basePanel = new JPanel();
76 final JLabel imageLabel = new JLabel();
77 final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
78 imageLabel.setIcon(icon);
80 final JTextArea productField = createProductField();
81 productField.setOpaque(false);
82 productField.setBorder(BorderFactory.createEmptyBorder());
83 productField.setBackground(new Color(0, 0, 0, 0));
85 final JScrollPane licensePane = createLicensePane();
87 okButton.setText("OK");
88 okButton.addActionListener(this);
91 basePanel.setPreferredSize(new Dimension(500, 600));
92 GroupLayout gl = new GroupLayout(basePanel);
93 basePanel.setLayout(gl);
95 gl.setHorizontalGroup(gl.createParallelGroup(GroupLayout.Alignment.CENTER)
96 .addGroup(gl.createSequentialGroup()
97 .addGap(15).addComponent(imageLabel).addGap(30).addComponent(productField).addGap(30))
98 .addComponent(licensePane)
99 .addComponent(okButton));
101 gl.setVerticalGroup(gl.createSequentialGroup()
103 .addGroup(gl.createParallelGroup()
104 .addComponent(imageLabel).addComponent(productField))
106 .addComponent(licensePane)
107 .addComponent(okButton));
109 getContentPane().add(basePanel, null);
115 private JTextArea createProductField() {
116 final JTextArea area = new JTextArea();
117 area.append(VERSION);
118 area.append(LINE_FEED);
119 area.append(LINE_FEED);
121 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
122 "saccubus_description.txt"), "UTF-8"))) {
124 while ((line = reader.readLine()) != null) {
126 area.append(LINE_FEED);
128 } catch (IOException ex) {
129 logger.log(Level.SEVERE, null, ex);
132 area.setEditable(false);
136 private JScrollPane createLicensePane() {
137 final JTextArea licenseField = new JTextArea();
138 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
139 "LICENSE.txt"), "UTF-8"))) {
141 while ((line = reader.readLine()) != null) {
142 licenseField.append(line);
143 licenseField.append(LINE_FEED);
145 } catch (IOException ex) {
146 logger.log(Level.SEVERE, null, ex);
149 licenseField.setCaretPosition(0);
150 licenseField.setEditable(false);
151 final JScrollPane licensePane = new JScrollPane(licenseField);
162 public void actionPerformed(ActionEvent actionEvent) {
163 if (actionEvent.getSource() == okButton) {
168 public static void main(String[] args) {
169 SwingUtilities.invokeLater(new Runnable() {
173 MainFrame_AboutBox frame = new MainFrame_AboutBox();
175 frame.setVisible(true);