diff --git a/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java b/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java index 56817bd09..aa6f9e45b 100644 --- a/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java +++ b/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java @@ -4,6 +4,7 @@ import net.miginfocom.swing.MigLayout; import net.sf.openrocket.file.wavefrontobj.export.OBJExportOptions; import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.adaptors.DoubleModel; +import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.ComponentAssembly; import net.sf.openrocket.rocketcomponent.RocketComponent; @@ -17,6 +18,7 @@ import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JSpinner; import javax.swing.JToggleButton; +import java.awt.Window; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; @@ -117,6 +119,12 @@ public class OBJOptionChooser extends JPanel { // Refresh the UI after changing visibility OBJOptionChooser.this.revalidate(); OBJOptionChooser.this.repaint(); + + // Adjust the size of the parent dialog + Window window = GUIUtil.getWindowAncestor(OBJOptionChooser.this); + if (window != null) { + window.pack(); + } } }); this.add(advancedOptionsPanel); diff --git a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java index 4fac6edd7..9a08420d3 100644 --- a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java +++ b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java @@ -451,6 +451,16 @@ public class GUIUtil { table.getColumnModel().getColumn(col).setPreferredWidth(Math.min(widths[col], max) * 100); } } + + public static Window getWindowAncestor(Component c) { + while (c != null) { + if (c instanceof Window) { + return (Window) c; + } + c = c.getParent(); + } + return null; + } /** * Changes the style of the font of the specified border.