1 package net.sf.openrocket.gui.dialogs;
3 import java.awt.event.ActionEvent;
4 import java.awt.event.ActionListener;
5 import java.util.SortedSet;
6 import java.util.TreeSet;
8 import javax.swing.JButton;
9 import javax.swing.JDialog;
10 import javax.swing.JFrame;
11 import javax.swing.JLabel;
12 import javax.swing.JPanel;
13 import javax.swing.JScrollPane;
14 import javax.swing.JTextArea;
16 import net.miginfocom.swing.MigLayout;
17 import net.sf.openrocket.gui.components.URLLabel;
18 import net.sf.openrocket.gui.main.AboutDialog;
19 import net.sf.openrocket.util.GUIUtil;
20 import net.sf.openrocket.util.JarUtil;
21 import net.sf.openrocket.util.Prefs;
23 public class BugDialog extends JDialog {
25 public BugDialog(JFrame parent) {
26 super(parent, "Bug reporing", true);
28 JPanel panel = new JPanel(new MigLayout("fill"));
30 panel.add(new JLabel("Please report any bugs you encounter as instructed at "),
32 panel.add(new URLLabel(AboutDialog.OPENROCKET_URL), "wrap rel");
33 panel.add(new JLabel("This allows us to make OpenRocket an even better simulator."),
34 "gap para, wrap para");
36 panel.add(new JLabel("<html><em>Please copy and paste the following information " +
37 "to the end of your bug report:</em>"), "gap para, wrap");
40 StringBuilder sb = new StringBuilder();
42 sb.append("---------- Included system information ----------\n");
43 sb.append("OpenRocket version: " + Prefs.getVersion() + "\n");
44 sb.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
45 sb.append("System properties:\n");
48 SortedSet<String> keys = new TreeSet<String>();
49 for (Object key: System.getProperties().keySet()) {
50 keys.add((String)key);
53 for (String key: keys) {
54 String value = System.getProperty(key);
55 sb.append(" " + key + "=");
56 if (key.equals("line.separator")) {
57 for (char c: value.toCharArray()) {
58 sb.append(String.format("\\u%04x", (int)c));
66 sb.append("---------- End system information ----------\n");
69 JTextArea text = new JTextArea(sb.toString(), 15, 70);
70 text.setEditable(false);
71 panel.add(new JScrollPane(text), "grow, wrap para");
73 JButton close = new JButton("Close");
74 close.addActionListener(new ActionListener() {
76 public void actionPerformed(ActionEvent e) {
77 BugDialog.this.dispose();
80 panel.add(close, "right");
85 this.setLocationRelativeTo(parent);
86 GUIUtil.installEscapeCloseOperation(this);
87 GUIUtil.setDefaultButton(close);