public void mouseDragged(MouseEvent e) {
		if( mouseOffset != -1 ) {
			double pos = 0;
			if( orientation == HORIZONTAL ) {
				mouseCoord = e.getX();

				pos = (mouseCoord - sliderLeftPadding - mouseOffset) / ((double)getEffectiveWidth()) ;
			} else {
                mouseCoord = e.getY();

                pos = (getHeight() - mouseCoord + mouseOffset) / ((double)getEffectiveWidth()) ;
			}

			// calculate appropriate value for parameter:
			pos *= boundedRangeModel.getMaximum() - boundedRangeModel.getMinimum();
			int val ;
			if( snapToTicks ) {
				int spacing = 1;
				if( minorTickSpacing != -1 )
					spacing = minorTickSpacing ;
				if( majorTickSpacing != -1 && majorTickSpacing < minorTickSpacing )
					spacing = majorTickSpacing ;
				val = ( (int) ( pos + spacing/2.0 + .5 ) ) ;
				val -= val % spacing ;
			} else {
				val = (int) ( pos + .5 );
			}
            val += boundedRangeModel.getMinimum();
			if( val > boundedRangeModel.getMaximum() )
				val = boundedRangeModel.getMaximum();
			if( val < boundedRangeModel.getMinimum() )
				val = boundedRangeModel.getMinimum();

            boundedRangeModel.setValue(val);
            repaint();
		}
        ChangeEvent ce = new ChangeEvent(this);
        for( ChangeListener l : listeners )
            l.stateChanged(ce);
	}