Startup
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
@@ -25,9 +26,10 @@ public class ManipulatorScan extends Panel {
|
||||
initComponents();
|
||||
|
||||
//Component persistence
|
||||
ArrayList<Component> persistedComponents = new ArrayList<>();
|
||||
ArrayList<Component> persistedComponents = new ArrayList<>();
|
||||
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JToggleButton.class)));
|
||||
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JSpinner.class)));
|
||||
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JSpinner.class)));
|
||||
persistedComponents.addAll(Arrays.asList(SwingUtils.getComponentsByType(this, JComboBox.class)));
|
||||
setPersistedComponents(persistedComponents.toArray(new Component[0]));
|
||||
|
||||
}
|
||||
@@ -572,12 +574,19 @@ public class ManipulatorScan extends Panel {
|
||||
try {
|
||||
Motor motor = (Motor) getDevice(comboMotor.getSelectedItem().toString());
|
||||
motorPanel.setDevice(motor);
|
||||
spinnerFrom.setModel(new SpinnerNumberModel(motor.getMinValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
|
||||
spinnerTo.setModel(new SpinnerNumberModel(motor.getMaxValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
|
||||
txtSize.setText("Size (" + motor.getUnit() +")");
|
||||
//spinnerFrom.setModel(new javax.swing.SpinnerNumberModel(3.0, 0.001, 100.0, 1.0));
|
||||
//spinnerTo.setModel(new javax.swing.SpinnerNumberModel(2.0, 0.001, 100.0, 1.0));
|
||||
if (motor!=null){
|
||||
//Try to reload existing values
|
||||
try{
|
||||
spinnerFrom.setModel(new SpinnerNumberModel(Math.max(motor.getMinValue(),(Double)spinnerFrom.getValue()), motor.getMinValue(), motor.getMaxValue(), 1.0));
|
||||
spinnerTo.setModel(new SpinnerNumberModel(Math.min(motor.getMaxValue(),(Double)spinnerTo.getValue()), motor.getMinValue(), motor.getMaxValue(), 1.0));
|
||||
} catch (Exception ex){
|
||||
spinnerFrom.setModel(new SpinnerNumberModel(motor.getMinValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
|
||||
spinnerTo.setModel(new SpinnerNumberModel(motor.getMaxValue(), motor.getMinValue(), motor.getMaxValue(), 1.0));
|
||||
}
|
||||
txtSize.setText("Size (" + motor.getUnit() +")");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
SwingUtils.showException(this, ex);
|
||||
}
|
||||
}//GEN-LAST:event_comboMotorActionPerformed
|
||||
|
||||
Reference in New Issue
Block a user