Skip to content

Commit

Permalink
Clickable link to GitHub in About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalucha committed Jan 13, 2017
1 parent da306c5 commit 95ac078
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Binary file modified distrib/kSar2-0.0.1.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions src/net/atomique/ksar/UI/AboutBox.form
Expand Up @@ -78,8 +78,18 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="urllabel">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="0" red="66" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="https://github.com/ppalucha/ksar2"/>
<Property name="toolTipText" type="java.lang.String" value="Go to project&apos;s website"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Hand Cursor"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="urllabelMouseClicked"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="authorlabel">
<Properties>
Expand Down
34 changes: 34 additions & 0 deletions src/net/atomique/ksar/UI/AboutBox.java
Expand Up @@ -12,6 +12,10 @@
package net.atomique.ksar.UI;

import java.awt.Dimension;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import net.atomique.ksar.VersionNumber;

/**
Expand Down Expand Up @@ -84,7 +88,15 @@ private void initComponents() {

jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS));

urllabel.setForeground(new java.awt.Color(102, 0, 255));
urllabel.setText("https://github.com/ppalucha/ksar2");
urllabel.setToolTipText("Go to project's website");
urllabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
urllabel.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
urllabelMouseClicked(evt);
}
});
jPanel2.add(urllabel);

authorlabel.setText("Author: Paweł Pałucha");
Expand Down Expand Up @@ -116,6 +128,28 @@ private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
dispose();
}//GEN-LAST:event_OkButtonActionPerformed

private void urllabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_urllabelMouseClicked
/* Some people say this is the cross-platform solution for opening link in Java */
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
/* Windows, Linux with GTK2, Max (?) */
try {
Desktop.getDesktop().browse(new URI(urllabel.getText()));
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
/* Linux without GTK2 libraries */
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(new String[]{"xdg-open", urllabel.getText()});
} catch (IOException e) {
e.printStackTrace();
}
}
}//GEN-LAST:event_urllabelMouseClicked



// Variables declaration - do not modify//GEN-BEGIN:variables
Expand Down

0 comments on commit 95ac078

Please sign in to comment.