3 import java.net.URISyntaxException;
4 import static javax.swing.WindowConstants.*;
7 import java.awt.Desktop;
8 import java.awt.Dimension;
10 import java.awt.event.ActionEvent;
11 import java.awt.event.ActionListener;
12 import java.io.BufferedReader;
13 import java.io.IOException;
14 import java.io.InputStreamReader;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18 import javax.swing.BorderFactory;
19 import javax.swing.GroupLayout;
20 import javax.swing.GroupLayout.Alignment;
21 import javax.swing.ImageIcon;
22 import javax.swing.JButton;
23 import javax.swing.JDialog;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JScrollPane;
27 import javax.swing.JTabbedPane;
28 import javax.swing.JTextArea;
29 import javax.swing.LayoutStyle.ComponentPlacement;
30 import javax.swing.SwingUtilities;
38 * 説明: ニコニコ動画の動画をコメントつきで保存
42 * 著作権: Copyright (c) 2007 PSI
52 public class MainFrame_AboutBox extends JDialog implements ActionListener {
54 public static final String VERSION = "いんきゅばす 2.2.1";
55 private static final long serialVersionUID = -4256413309312729840L;
56 private static final Logger logger = LoggerFactory.getLogger(MainFrame_AboutBox.class);
57 private static final String LINE_FEED = System.getProperty("line.separator");
58 private final JButton btnOk = new JButton();
60 public MainFrame_AboutBox(Frame parent) {
63 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
65 } catch (Exception exception) {
66 logger.error(null, exception);
70 public MainFrame_AboutBox() {
77 * @throws java.lang.Exception
79 private void jbInit() {
80 final JTabbedPane tab = new JTabbedPane(JTabbedPane.BOTTOM);
82 final JLabel lblImage = new JLabel();
83 final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
84 lblImage.setIcon(icon);
86 final JTextArea fldProduct = createProductField();
88 // http://stackoverflow.com/questions/613603/java-nimbus-laf-with-transparent-text-fields
89 fldProduct.setOpaque(false);
90 fldProduct.setBorder(BorderFactory.createEmptyBorder());
91 fldProduct.setBackground(new Color(0, 0, 0, 0));
93 final JButton btnInqubus = new JButton("いんきゅばすホームページへ...");
94 btnInqubus.addActionListener(new ActionListener() {
97 public void actionPerformed(ActionEvent e) {
98 if (Desktop.isDesktopSupported()) {
100 Desktop.getDesktop().browse(new URI("http://sourceforge.jp/projects/coroid/wiki/InqubusV2"));
101 } catch (IOException | URISyntaxException ex) {
102 logger.error(null, ex);
108 final JButton btnSaccubus = new JButton("さきゅばすホームページへ...");
109 btnSaccubus.addActionListener(new ActionListener() {
112 public void actionPerformed(ActionEvent e) {
113 if (Desktop.isDesktopSupported()) {
115 Desktop.getDesktop().browse(new URI("http://saccubus.sourceforge.jp/"));
116 } catch (IOException | URISyntaxException ex) {
117 logger.error(null, ex);
123 final JPanel pnlAbout = new JPanel();
124 GroupLayout glAbout = new GroupLayout(pnlAbout);
125 pnlAbout.setLayout(glAbout);
126 glAbout.setAutoCreateContainerGaps(true);
127 glAbout.setAutoCreateGaps(true);
129 glAbout.setHorizontalGroup(glAbout.createParallelGroup(GroupLayout.Alignment.CENTER)
130 .addGroup(glAbout.createSequentialGroup()
131 .addComponent(lblImage)
132 .addPreferredGap(ComponentPlacement.UNRELATED)
133 .addComponent(fldProduct)
135 .addGroup(glAbout.createSequentialGroup()
136 .addComponent(btnInqubus)
137 .addComponent(btnSaccubus)
141 glAbout.setVerticalGroup(glAbout.createSequentialGroup()
142 .addGroup(glAbout.createParallelGroup()
143 .addComponent(lblImage)
144 .addComponent(fldProduct, 0, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
146 .addGroup(glAbout.createParallelGroup()
147 .addComponent(btnInqubus)
148 .addComponent(btnSaccubus)
152 tab.add("About", pnlAbout);
154 final JScrollPane pnlLicense = createLicensePane();
155 tab.add("License", pnlLicense);
158 btnOk.addActionListener(this);
160 final JPanel pnlBase = new JPanel();
161 final GroupLayout glBase = new GroupLayout(pnlBase);
162 pnlBase.setLayout(glBase);
163 glBase.setAutoCreateContainerGaps(true);
164 glBase.setAutoCreateGaps(true);
166 glBase.setHorizontalGroup(glBase.createParallelGroup(Alignment.CENTER)
171 glBase.setVerticalGroup(glBase.createSequentialGroup()
177 setContentPane(pnlBase);
184 private JTextArea createProductField() {
185 final JTextArea area = new JTextArea();
186 area.append(VERSION);
187 area.append(" (NicoBrowser " + nicobrowser.main.Main.VERSION + ")");
188 area.append(LINE_FEED);
189 area.append(LINE_FEED);
191 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
192 "saccubus_description.txt"), "UTF-8"))) {
194 while ((line = reader.readLine()) != null) {
196 area.append(LINE_FEED);
198 } catch (IOException ex) {
199 logger.error(null, ex);
202 area.setEditable(false);
206 private JScrollPane createLicensePane() {
207 final JTextArea licenseField = new JTextArea();
208 try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
209 "LICENSE.txt"), "UTF-8"))) {
211 while ((line = reader.readLine()) != null) {
212 licenseField.append(line);
213 licenseField.append(LINE_FEED);
215 } catch (IOException ex) {
216 logger.error(null, ex);
219 licenseField.setCaretPosition(0);
220 licenseField.setEditable(false);
221 final JScrollPane licensePane = new JScrollPane(licenseField);
222 licensePane.setPreferredSize(new Dimension(400, 400));
233 public void actionPerformed(ActionEvent actionEvent) {
234 if (actionEvent.getSource() == btnOk) {
239 public static void main(String[] args) {
240 SwingUtilities.invokeLater(new Runnable() {
244 MainFrame_AboutBox frame = new MainFrame_AboutBox();
246 frame.setVisible(true);