1 package net.sf.openrocket.gui.dialogs;
4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
6 import java.io.BufferedReader;
7 import java.io.InputStreamReader;
9 import javax.swing.JButton;
10 import javax.swing.JDialog;
11 import javax.swing.JFrame;
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.StyledLabel;
18 import net.sf.openrocket.util.GUIUtil;
20 public class LicenseDialog extends JDialog {
21 private static final String LICENSE_FILENAME = "LICENSE.TXT";
23 private static final String DEFAULT_LICENSE_TEXT =
25 "Error: Unable to load " + LICENSE_FILENAME + "!\n" +
27 "OpenRocket is licensed under the GNU GPL version 3, with additional permissions.\n" +
28 "See http://openrocket.sourceforge.net/ for details.";
30 public LicenseDialog(JFrame parent) {
33 JPanel panel = new JPanel(new MigLayout("fill"));
35 panel.add(new StyledLabel("OpenRocket license", 10), "ax 50%, wrap para");
40 BufferedReader reader = new BufferedReader(
41 new InputStreamReader(ClassLoader.getSystemResourceAsStream(LICENSE_FILENAME)));
42 StringBuffer sb = new StringBuffer();
43 for (String s = reader.readLine(); s != null; s = reader.readLine()) {
47 licenseText = sb.toString();
49 } catch (Exception e) {
51 licenseText = DEFAULT_LICENSE_TEXT;
55 JTextArea text = new JTextArea(licenseText);
56 text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
59 text.setEditable(false);
60 panel.add(new JScrollPane(text),"grow, wrap para");
62 JButton close = new JButton("Close");
63 close.addActionListener(new ActionListener() {
65 public void actionPerformed(ActionEvent e) {
66 LicenseDialog.this.dispose();
69 panel.add(close, "right");
72 this.setTitle("OpenRocket license");
74 this.setLocationRelativeTo(parent);
76 GUIUtil.setDisposableDialogOptions(this, close);