this.latitudeLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, CompassPanel.class, "latitudeLabel.text"));
final SpinnerNumberModel latitudeSpinnerModel = new SpinnerNumberModel(new Float(0), new Float(-90), new Float(90), new Float(5));
this.latitudeSpinner = new JSpinner(latitudeSpinnerModel);
// Change positive / negative notation by North / South
JFormattedTextField textField = ((DefaultEditor)this.latitudeSpinner.getEditor()).getTextField();
NumberFormatter numberFormatter = (NumberFormatter)((DefaultFormatterFactory)textField.getFormatterFactory()).getDefaultFormatter();
numberFormatter.setFormat(new DecimalFormat("N ##0.000;S ##0.000"));
textField.setFormatterFactory(new DefaultFormatterFactory(numberFormatter));
SwingTools.addAutoSelectionOnFocusGain(textField);
latitudeSpinnerModel.setValue(controller.getLatitudeInDegrees());
final PropertyChangeListener latitudeChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
latitudeSpinnerModel.setValue((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(CompassController.Property.LATITUDE_IN_DEGREES, latitudeChangeListener);
latitudeSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(CompassController.Property.LATITUDE_IN_DEGREES, latitudeChangeListener);
controller.setLatitudeInDegrees(((Number)latitudeSpinnerModel.getValue()).floatValue());
controller.addPropertyChangeListener(CompassController.Property.LATITUDE_IN_DEGREES, latitudeChangeListener);
}
});
this.longitudeLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, CompassPanel.class, "longitudeLabel.text"));
final SpinnerNumberModel longitudeSpinnerModel = new SpinnerNumberModel(new Float(0), new Float(-180), new Float(180), new Float(5));
this.longitudeSpinner = new JSpinner(longitudeSpinnerModel);
// Change positive / negative notation by East / West
textField = ((DefaultEditor)this.longitudeSpinner.getEditor()).getTextField();
numberFormatter = (NumberFormatter)((DefaultFormatterFactory)textField.getFormatterFactory()).getDefaultFormatter();
numberFormatter.setFormat(new DecimalFormat("E ##0.000;W ##0.000"));
textField.setFormatterFactory(new DefaultFormatterFactory(numberFormatter));
SwingTools.addAutoSelectionOnFocusGain(textField);
longitudeSpinnerModel.setValue(controller.getLongitudeInDegrees());
final PropertyChangeListener longitudeChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
longitudeSpinnerModel.setValue((Float)ev.getNewValue());