From 674ae0d13338b9f4be47a8a416e0413de1aeeee8 Mon Sep 17 00:00:00 2001 From: deathmarine Date: Thu, 17 Nov 2016 16:23:47 -0500 Subject: [PATCH] Added Links and Updated the About dialog --- src/us/deathmarine/luyten/Luyten.java | 27 ++++++++ src/us/deathmarine/luyten/MainMenuBar.java | 75 +++++++++++++++++++--- 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/src/us/deathmarine/luyten/Luyten.java b/src/us/deathmarine/luyten/Luyten.java index 120dd80..43d0622 100644 --- a/src/us/deathmarine/luyten/Luyten.java +++ b/src/us/deathmarine/luyten/Luyten.java @@ -1,6 +1,8 @@ package us.deathmarine.luyten; import java.awt.Component; +import java.awt.Cursor; +import java.awt.Desktop; import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.ActionEvent; @@ -14,6 +16,8 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; +import java.net.URI; +import java.net.URISyntaxException; import java.util.concurrent.atomic.AtomicReference; import java.util.List; import java.util.ArrayList; @@ -128,6 +132,7 @@ public static String getVersion(){ /** * Method allows for users to copy the stacktrace for reporting any issues. + * Add Cool Hyperlink * Enhanced for mouse users. * * @param message @@ -186,6 +191,28 @@ public void actionPerformed(ActionEvent e) { JScrollPane scroll = new JScrollPane(exception); scroll.setBorder(new CompoundBorder(BorderFactory.createTitledBorder("Stacktrace"),new BevelBorder(BevelBorder.LOWERED))); pane.add(scroll); + final String issue = "https://github.com/deathmarine/Luyten/issues"; + final JLabel link = new JLabel("Submit to "+issue+""); + link.setCursor(new Cursor(Cursor.HAND_CURSOR)); + link.addMouseListener(new MouseAdapter(){ + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI(issue)); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + @Override + public void mouseEntered(MouseEvent e) { + link.setText("Submit to "+issue+""); + } + @Override + public void mouseExited(MouseEvent e) { + link.setText("Submit to "+issue+""); + } + }); + pane.add(link); JOptionPane.showMessageDialog(null, pane, "Error!", JOptionPane.ERROR_MESSAGE); } } diff --git a/src/us/deathmarine/luyten/MainMenuBar.java b/src/us/deathmarine/luyten/MainMenuBar.java index 43d2349..100d127 100644 --- a/src/us/deathmarine/luyten/MainMenuBar.java +++ b/src/us/deathmarine/luyten/MainMenuBar.java @@ -3,19 +3,28 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.net.URI; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Font; import java.awt.Toolkit; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.swing.AbstractAction; import javax.swing.AbstractButton; +import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.ButtonModel; import javax.swing.JCheckBox; +import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.JRadioButtonMenuItem; import javax.swing.KeyStroke; import javax.swing.text.DefaultEditorKit; @@ -474,14 +483,38 @@ public void actionPerformed(ActionEvent e) { menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - JOptionPane.showMessageDialog(null, - "Luyten " + Luyten.getVersion() + - "\nby Deathmarine, Zerdei\n\n" + - "Powered By\nProcyon "+ Procyon.version()+ - "\n(c) 2015 Mike Strobel\n\n" + - "RSyntaxTextArea\n" + - "(c) 2012 Robert Futrell\n" + - "All rights reserved."); + JPanel pane = new JPanel(); + pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS)); + JLabel title = new JLabel("Luyten "+Luyten.getVersion()); + title.setFont(new Font(Font.SANS_SERIF,Font.PLAIN,18)); + pane.add(title); + pane.add(new JLabel("by Deathmarine")); + String project = "https://github.com/deathmarine/Luyten/"; + JLabel link = new JLabel(""+project+""); + link.setCursor(new Cursor(Cursor.HAND_CURSOR)); + link.addMouseListener(new LinkListener(project, link)); + pane.add(link); + pane.add(new JLabel("Contributions By:")); + pane.add(new JLabel("zerdei, toonetown, dstmath")); + pane.add(new JLabel("virustotalop, xtrafrancyz")); + pane.add(new JLabel("mbax, quitten, and mstrobel")); + pane.add(new JLabel(" ")); + pane.add(new JLabel("Powered By:")); + String procyon = "https://bitbucket.org/mstrobel/procyon"; + link = new JLabel(""+procyon+""); + link.setCursor(new Cursor(Cursor.HAND_CURSOR)); + link.addMouseListener(new LinkListener(procyon, link)); + pane.add(link); + pane.add(new JLabel("Version:"+Procyon.version())); + pane.add(new JLabel("(c) 2016 Mike Strobel")); + String rsyntax = "https://github.com/bobbylight/RSyntaxTextArea"; + link = new JLabel(""+rsyntax+""); + link.setCursor(new Cursor(Cursor.HAND_CURSOR)); + link.addMouseListener(new LinkListener(rsyntax, link)); + pane.add(link); + pane.add(new JLabel("(c) 2016 Robert Futrell")); + pane.add(new JLabel(" ")); + JOptionPane.showMessageDialog(null,pane); } }); helpMenu.add(menuItem); @@ -540,4 +573,30 @@ public void actionPerformed(ActionEvent e) { mainWindow.onThemesChanged(); } } + + private class LinkListener extends MouseAdapter{ + String link; + JLabel label; + public LinkListener(String link, JLabel label){ + this.link = link; + this.label = label; + } + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI(link)); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + @Override + public void mouseEntered(MouseEvent e) { + label.setText(""+link+""); + } + @Override + public void mouseExited(MouseEvent e) { + label.setText(""+link+""); + } + + } }