From: yukihane Date: Sat, 20 Aug 2011 19:43:57 +0000 (+0900) Subject: バージョン情報ダイアログをtry-with-resourcesを使って書き換え X-Git-Tag: test20110903_ver2.a.0~195 X-Git-Url: http://git.sourceforge.jp/view?p=coroid%2Finqubus.git;a=commitdiff_plain;h=de24139cd13c3f1c595fc4ea5ff1c12b725c4ae8 バージョン情報ダイアログをtry-with-resourcesを使って書き換え --- diff --git a/frontend/src/saccubus/MainFrame_AboutBox.java b/frontend/src/saccubus/MainFrame_AboutBox.java index 9d8ab8c..fd69a25 100644 --- a/frontend/src/saccubus/MainFrame_AboutBox.java +++ b/frontend/src/saccubus/MainFrame_AboutBox.java @@ -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; @@ -83,7 +82,7 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener { * * @throws java.lang.Exception */ - private void jbInit() throws Exception { + private void jbInit() { final JPanel basePanel = new JPanel(); final JLabel imageLabel = new JLabel(); @@ -124,23 +123,19 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener { setResizable(true); } - private JScrollPane createLicensePane() throws IOException { + private JScrollPane createLicensePane() { 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")); - + 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);