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.IOException;
8 import java.io.InputStreamReader;
10 import javax.swing.JButton;
11 import javax.swing.JDialog;
12 import javax.swing.JFrame;
13 import javax.swing.JPanel;
14 import javax.swing.JScrollPane;
15 import javax.swing.JTextArea;
17 import net.miginfocom.swing.MigLayout;
18 import net.sf.openrocket.gui.components.StyledLabel;
19 import net.sf.openrocket.gui.util.GUIUtil;
20 import net.sf.openrocket.l10n.Translator;
21 import net.sf.openrocket.startup.Application;
23 public class LicenseDialog extends JDialog {
24 private static final String LICENSE_FILENAME = "LICENSE.TXT";
25 private static final Translator trans = Application.getTranslator();
27 private static final String DEFAULT_LICENSE_TEXT =
29 "Error: Unable to load " + LICENSE_FILENAME + "!\n" +
31 "OpenRocket is licensed under the GNU GPL version 3, with additional permissions.\n" +
32 "See http://openrocket.sourceforge.net/ for details.";
34 public LicenseDialog(JFrame parent) {
37 JPanel panel = new JPanel(new MigLayout("fill"));
39 panel.add(new StyledLabel("OpenRocket license", 10), "ax 50%, wrap para");
44 BufferedReader reader = new BufferedReader(
45 new InputStreamReader(ClassLoader.getSystemResourceAsStream(LICENSE_FILENAME)));
46 StringBuffer sb = new StringBuffer();
47 for (String s = reader.readLine(); s != null; s = reader.readLine()) {
51 licenseText = sb.toString();
53 } catch (IOException e) {
55 licenseText = DEFAULT_LICENSE_TEXT;
59 JTextArea text = new JTextArea(licenseText);
60 text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
63 text.setEditable(false);
64 panel.add(new JScrollPane(text),"grow, wrap para");
67 JButton close = new JButton(trans.get("dlg.but.close"));
68 close.addActionListener(new ActionListener() {
70 public void actionPerformed(ActionEvent e) {
71 LicenseDialog.this.dispose();
74 panel.add(close, "right");
77 this.setTitle("OpenRocket license");
79 this.setLocationRelativeTo(parent);
81 GUIUtil.setDisposableDialogOptions(this, close);