Code example for JSlider

Methods: addChangeListener

0
		registerTemperatureSlider(view);
	} 
 
	private void registerTemperatureSlider(final TemperatureView view) {
		final JSlider temperatureSlider = view.getTemperatureSlider();
		temperatureSlider.addChangeListener(new ChangeListener() {
			@Override 
			public void stateChanged(ChangeEvent arg0) {
				int value = temperatureSlider.getValue();
				setTemperature(value);
			} 
		}); 
	} 
 
	protected void setTemperature(double value) {
		final TemperatureModel model = (TemperatureModel) mSensorModel;
		final TemperatureView view = (TemperatureView) mSensorView;
		if (model.getReadTemp() != value) {
			model.setTemp(value);
			view.setTemp(value);