From 0e7c088c9424473db39e97bdde09437f3ccfc16a Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 10 Feb 2022 20:18:11 +0100 Subject: [PATCH] Fix license layout issues --- .../gui/components/DescriptionArea.java | 17 +++++++++++++---- .../openrocket/gui/dialogs/LicenseDialog.java | 15 ++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java index 9c373e261..91a5ad2a8 100644 --- a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java +++ b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java @@ -12,19 +12,16 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import javax.swing.JTextPane; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.JEditorPane; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; import javax.swing.SwingUtilities; -import net.sf.openrocket.util.BugException; - @SuppressWarnings("serial") public class DescriptionArea extends JScrollPane { @@ -180,5 +177,17 @@ public class DescriptionArea extends JScrollPane { }); editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); } + + /** + * Set the font to use for the text pane. If null, then the default font from OR is used. + * @param font font to use + */ + public void setTextFont(Font font) { + if (editorPane == null) return; + editorPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true); + if (font != null) { + editorPane.setFont(font); + } + } } diff --git a/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java index edfde1bda..0a140ac7b 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java @@ -1,21 +1,13 @@ package net.sf.openrocket.gui.dialogs; -import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.net.URL; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; import net.miginfocom.swing.MigLayout; import net.sf.openrocket.gui.components.DescriptionArea; @@ -39,7 +31,7 @@ public class LicenseDialog extends JDialog { // OpenRocket logo panel.add(new JLabel(Icons.loadImageIcon("pix/icon/icon-about.png", "OpenRocket")), "top"); - panel.add(new StyledLabel("Software Licenses", 10), "ax 50%, wrap para"); + panel.add(new StyledLabel("Software Licenses", 10), "ax 50%, pushx, wrap para"); final String jarUrl = "jar:" + getClass().getProtectionDomain().getCodeSource().getLocation().toString(); final String copyrightYear = BuildProperties.getCopyrightYear(); @@ -146,8 +138,9 @@ public class LicenseDialog extends JDialog { /*****************************************************************************************************************************/ DescriptionArea info = new DescriptionArea(20); + info.setTextFont(null); info.setText(orLicense + componentsLicense + fontLicense + commonmarkLicense); - panel.add(info, "newline, width 600lp, height 150lp, grow, spanx, wrap para"); + panel.add(info, "newline, width 700lp, height 250lp, pushy, grow, spanx, wrap para"); //Close button JButton close = new SelectColorButton(trans.get("dlg.but.close")); @@ -157,7 +150,7 @@ public class LicenseDialog extends JDialog { LicenseDialog.this.dispose(); } }); - panel.add(close, "right"); + panel.add(close, "spanx, right"); this.add(panel); this.setTitle("OpenRocket license");