Code example for JSlider

Methods: getMaximumgetMinimumgetValue

0
	public void stateChanged(ChangeEvent e) {
		// slider value changed 
		JSlider source = (JSlider) e.getSource();
		double value;
		if (logarithmic) {
			value = (double) (source.getValue() - source.getMinimum())
					/ (source.getMaximum() - source.getMinimum());
			double logMin = Math.log(min);
			double logMax = Math.log(max);
			double scale = logMax - logMin;
			value = Math.pow(Math.E, value * scale + logMin);
		} else { 
			double scale = (max - min) / (source.getMaximum() - source.getMinimum());
			value = (source.getValue() - source.getMinimum()) * scale + min;
		} 
		setTextField(value);
		valueChanged(value);
	} 
 
	/**