jTracer  1.03
Stack trace visualization tool
AboutDialog.java
Go to the documentation of this file.
1 
7 package org.libcsdbg.jtracer;
8 
9 import java.io.File;
10 
11 import java.net.URL;
12 
13 import java.awt.Insets;
14 import java.awt.Dimension;
15 import java.awt.BorderLayout;
16 
17 import javax.swing.event.HyperlinkEvent;
18 import javax.swing.event.HyperlinkListener;
19 import javax.swing.WindowConstants;
20 import javax.swing.JDialog;
21 import javax.swing.JFrame;
22 import javax.swing.JEditorPane;
23 
30 public class AboutDialog extends JDialog implements HyperlinkListener
31 {
33  private static final long serialVersionUID = 0x00;
34 
35 
41  AboutDialog(JFrame owner)
42  {
43  super(owner, true);
44  Registry conf = Registry.getCurrent();
45  setTitle("About " + (String) conf.get("generic", "name"));
46 
47  try {
48  File page = conf.getResource("var/about.html");
49  JEditorPane viewer = new JEditorPane(page.toURI().toURL());
50 
51  viewer.putClientProperty(JEditorPane.W3C_LENGTH_UNITS, true);
52  viewer.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
53  viewer.setEditable(false);
54  viewer.setFocusable(false);
55  viewer.setMargin(new Insets(0, 0, 0, 0));
56  if (Registry.isLinux())
57  viewer.setPreferredSize(new Dimension(334, 380));
58  else
59  viewer.setPreferredSize(new Dimension(334, 400));
60 
61  viewer.addHyperlinkListener(this);
62  add(viewer, BorderLayout.CENTER);
63  }
64 
65  catch (Throwable t) {
66  Registry.debug(t);
67  dispose();
68  return;
69  }
70 
71  setResizable(false);
72  setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
73  pack();
74  }
75 
76 
82  public void hyperlinkUpdate(HyperlinkEvent event)
83  {
84  try {
85  if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
86  return;
87 
88  URL url = event.getURL();
89  String proto = url.getProtocol();
90  Registry conf = Registry.getCurrent();
91 
92  if (proto.equals("file"))
93  setVisible(false);
94 
95  else if (proto.equals("mailto"))
96  conf.mail(url);
97 
98  else if (proto.equals("http"))
99  conf.browse(url);
100  }
101 
102  catch (Throwable t) {
103  Registry.debug(t);
104  }
105  }
106 }
107 
Object get(String section, String key)
Get an entry.
Definition: Registry.java:151
Configuration registry.
Definition: Registry.java:41
void mail(URL url)
Open a URL on the registered mail composer.
Definition: Registry.java:264
static boolean isLinux()
Definition: Registry.java:433
A dialog that shows an HTML page with project information (version, short description, license, copyright e.t.c) and links to various online project resources.
static final long serialVersionUID
Class version.
void hyperlinkUpdate(HyperlinkEvent event)
Handler for hyperlink events.