diff --git a/src/main/java/musicplayer/PlayerGUI.java b/src/main/java/musicplayer/PlayerGUI.java index dcd5d6f..ba4b57b 100644 --- a/src/main/java/musicplayer/PlayerGUI.java +++ b/src/main/java/musicplayer/PlayerGUI.java @@ -27,12 +27,12 @@ import java.awt.event.ItemEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.net.URISyntaxException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.*; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -503,22 +503,21 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf JMenu helpMenu = new JMenu("Help"); menuItem = new JMenuItem("About"); menuItem.addActionListener(e -> { - try { - //noinspection ConstantConditions - JEditorPane messagePane = new JEditorPane("text/html", Files.readAllLines( - Paths.get(PlayerGUI.class.getClassLoader().getResource("LICENSE.txt").toURI())).get(0)); + try(BufferedReader reader = new BufferedReader(new InputStreamReader(PlayerGUI.class.getClassLoader().getResourceAsStream("LICENSE.txt")))) { + JEditorPane messagePane = new JEditorPane("text/html", reader.lines().collect(Collectors.toList()).get(0)); messagePane.setEditable(false); - messagePane.addHyperlinkListener(hl -> { + messagePane.addHyperlinkListener(hl -> + { if (hl.getEventType() == HyperlinkEvent.EventType.ACTIVATED) - if(Desktop.isDesktopSupported()) + if (Desktop.isDesktopSupported()) try { Desktop.getDesktop().browse(hl.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } }); - JOptionPane.showMessageDialog(mainPanel, messagePane, "About", JOptionPane.INFORMATION_MESSAGE); - } catch (IOException | URISyntaxException e1) { + JOptionPane.showMessageDialog(mainPanel,messagePane,"About",JOptionPane.INFORMATION_MESSAGE); + } catch (IOException e1) { e1.printStackTrace(); } });