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 source: " + Prefs.getBuildSource() + "\n");
45 sb.append("OpenRocket location: " + JarUtil.getCurrentJarFile() + "\n");
46 sb.append("System properties:\n");
49 SortedSet<String> keys = new TreeSet<String>();
50 for (Object key: System.getProperties().keySet()) {
51 keys.add((String)key);
54 for (String key: keys) {
55 String value = System.getProperty(key);
56 sb.append(" " + key + "=");
57 if (key.equals("line.separator")) {
58 for (char c: value.toCharArray()) {
59 sb.append(String.format("\\u%04x", (int)c));
67 sb.append("---------- End system information ----------\n");
70 JTextArea text = new JTextArea(sb.toString(), 15, 70);
71 text.setEditable(false);
72 panel.add(new JScrollPane(text), "grow, wrap para");
74 JButton close = new JButton("Close");
75 close.addActionListener(new ActionListener() {
77 public void actionPerformed(ActionEvent e) {
78 BugDialog.this.dispose();
81 panel.add(close, "right");
86 this.setLocationRelativeTo(parent);
87 GUIUtil.installEscapeCloseOperation(this);
88 GUIUtil.setDefaultButton(close);