Fix problematic bug in motor selection which manifested as:
java.lang.IllegalArgumentException: setSelectedIndex: 0 out of bounds at javax.swing.JComboBox.setSelectedIndex(Unknown Source) at net.sf.openrocket.gui.dialogs.motor.thrustcurve.ThrustCurveMotorSelectionPanel.updateData(ThrustCurveMotorSelectionPanel.java:437) The underlying problem was the MotorChooserDialog had been using the GUIUtil.setDisposableDialogOptions call which caused all the underlying models to be cleared when the dialog was closed with the "x" button. This caused the reference to the models in the panel to be disassociated with those in the swing widgets. Since the dialog is reused, this behavior was bad. Changed the dialog so the 'x' button simply hides the dialog and use the GUIUtil.installEscapeCloseOperation to wire in the ESC key.
This commit is contained in:
parent
11a59e0759
commit
730abea70b
@ -10,6 +10,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.gui.dialogs.motor.thrustcurve.ThrustCurveMotorSelectionPanel;
|
||||
@ -34,6 +35,8 @@ public class MotorChooserDialog extends JDialog implements CloseableDialog {
|
||||
public MotorChooserDialog(Window owner) {
|
||||
super(owner, trans.get("MotorChooserDialog.title"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||
|
||||
// We're going to reuse this dialog so only hide it when it's closed.
|
||||
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||
|
||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||
|
||||
@ -67,7 +70,7 @@ public class MotorChooserDialog extends JDialog implements CloseableDialog {
|
||||
this.setModal(true);
|
||||
this.pack();
|
||||
this.setLocationByPlatform(true);
|
||||
GUIUtil.setDisposableDialogOptions(this, okButton);
|
||||
GUIUtil.installEscapeCloseOperation(this);
|
||||
|
||||
JComponent focus = selectionPanel.getDefaultFocus();
|
||||
if (focus != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user