3 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.GroupLayout.Alignment;
18 import javax.swing.ImageIcon;
19 import javax.swing.JButton;
20 import javax.swing.JDialog;
21 import javax.swing.JLabel;
22 import javax.swing.JPanel;
23 import javax.swing.JScrollPane;
24 import javax.swing.JTabbedPane;
25 import javax.swing.JTextArea;
26 import javax.swing.SwingUtilities;
34 * 説明: ニコニコ動画の動画をコメントつきで保存
38 * 著作権: Copyright (c) 2007 PSI
48 public class MainFrame_AboutBox extends JDialog implements ActionListener {
50 private static final String VERSION = "いんきゅばす 2.0.0";
51 private static final long serialVersionUID = -4256413309312729840L;
52 private static final Logger logger = Logger.getLogger(MainFrame_AboutBox.class.getName());
53 private static final String LINE_FEED = System.getProperty("line.separator");
54 private final JButton okButton = new JButton();
56 public MainFrame_AboutBox(Frame parent) {
59 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
61 } catch (Exception exception) {
62 logger.log(Level.SEVERE, null, exception);
66 public MainFrame_AboutBox() {
73 * @throws java.lang.Exception
75 private void jbInit() {
76 final JTabbedPane tab = new JTabbedPane(JTabbedPane.BOTTOM);
78 final JLabel lblImage = new JLabel();
79 final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
80 lblImage.setIcon(icon);
82 final JTextArea fldProduct = createProductField();
84 // http://stackoverflow.com/questions/613603/java-nimbus-laf-with-transparent-text-fields
85 fldProduct.setOpaque(false);
86 fldProduct.setBorder(BorderFactory.createEmptyBorder());
87 fldProduct.setBackground(new Color(0, 0, 0, 0));
89 final JScrollPane pnlLicense = createLicensePane();
91 okButton.setText("OK");
92 okButton.addActionListener(this);
95 final JPanel pnlAbout = new JPanel();
96 GroupLayout glAbout = new GroupLayout(pnlAbout);
97 pnlAbout.setLayout(glAbout);
99 glAbout.setHorizontalGroup(glAbout.createParallelGroup(GroupLayout.Alignment.CENTER)
100 .addGroup(glAbout.createSequentialGroup()
101 .addGap(15).addComponent(lblImage).addGap(30).addComponent(fldProduct).addGap(30))
104 glAbout.setVerticalGroup(glAbout.createSequentialGroup()
106 .addGroup(glAbout.createParallelGroup()
107 .addComponent(lblImage).addComponent(fldProduct))
111 tab.add("About", pnlAbout);
112 tab.add("License", pnlLicense);
114 final JPanel pnlBase = new JPanel();
115 final GroupLayout glBase = new GroupLayout(pnlBase);
116 pnlBase.setLayout(glBase);
117 glBase.setAutoCreateContainerGaps(true);
118 glBase.setAutoCreateGaps(true);
120 glBase.setHorizontalGroup(glBase.createParallelGroup(Alignment.CENTER)
122 .addComponent(okButton)
125 glBase.setVerticalGroup(glBase.createSequentialGroup()
127 .addComponent(okButton)
131 setContentPane(pnlBase);
138 private JTextArea createProductField() {
139 final JTextArea area = new JTextArea();
140 area.append(VERSION);
141 area.append(LINE_FEED);
142 area.append(LINE_FEED);
144 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
145 "saccubus_description.txt"), "UTF-8"))) {
147 while ((line = reader.readLine()) != null) {
149 area.append(LINE_FEED);
151 } catch (IOException ex) {
152 logger.log(Level.SEVERE, null, ex);
155 area.setEditable(false);
159 private JScrollPane createLicensePane() {
160 final JTextArea licenseField = new JTextArea();
161 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
162 "LICENSE.txt"), "UTF-8"))) {
164 while ((line = reader.readLine()) != null) {
165 licenseField.append(line);
166 licenseField.append(LINE_FEED);
168 } catch (IOException ex) {
169 logger.log(Level.SEVERE, null, ex);
172 licenseField.setCaretPosition(0);
173 licenseField.setEditable(false);
174 final JScrollPane licensePane = new JScrollPane(licenseField);
175 licensePane.setPreferredSize(new Dimension(400, 400));
186 public void actionPerformed(ActionEvent actionEvent) {
187 if (actionEvent.getSource() == okButton) {
192 public static void main(String[] args) {
193 SwingUtilities.invokeLater(new Runnable() {
197 MainFrame_AboutBox frame = new MainFrame_AboutBox();
199 frame.setVisible(true);