Bug in Scrollbar.java

gelderk at natlab.research.philips.com gelderk at natlab.research.philips.com
Mon Sep 7 00:45:31 PDT 1998


Hello,

Found two bugs in the Scrollbar source. Occurs when the minimum value
for the scrollbar is not zero.

Patch is below.

Yours,
Kero.

+--- Kero ----------------------------------+
| I ain't changed,                          |
| but I know I ain't the same               |
+--- M38C --- http://huizen.dds.nl/~kero ---+

*** libraries/javalib/java/awt/widgets/Scrollbar.java	Tue Jul 14 06:34:38 1998
--- Scrollbar.java	Wed Sep  2 11:11:15 1998
***************
*** 486,492 ****
  	//slider position from value
  	if ( ori == HORIZONTAL ) {
  		int dx = Math.max( vis * width / (delta + vis), 10);
! 		int x0 = val * ( width - dx ) / delta;
  		if ( x0 >= 0 )
  			slRect.setBounds( x0, 2, dx, height-4);
  		else
--- 486,492 ----
  	//slider position from value
  	if ( ori == HORIZONTAL ) {
  		int dx = Math.max( vis * width / (delta + vis), 10);
! 		int x0 = (val-min) * ( width - dx ) / delta;
  		if ( x0 >= 0 )
  			slRect.setBounds( x0, 2, dx, height-4);
  		else
***************
*** 495,501 ****
  	else {
  		//total amount is max - min + vis, for contents cannot be scrolled out
  		int dy = Math.max( vis * height / (delta + vis), 10);
! 		int y0 = val * ( height - dy ) / delta;	
  		if ( y0 >= 0 )
  			slRect.setBounds( 2, y0, width-4, dy);
  		else
--- 495,501 ----
  	else {
  		//total amount is max - min + vis, for contents cannot be scrolled out
  		int dy = Math.max( vis * height / (delta + vis), 10);
! 		int y0 = (val-min) * ( height - dy ) / delta;	
  		if ( y0 >= 0 )
  			slRect.setBounds( 2, y0, width-4, dy);
  		else
***************
*** 509,517 ****
  	int newVal;
  	
  	if ( ori == HORIZONTAL )
! 		newVal = slRect.x * ( max - min) / (width - slRect.width );
  	else
! 		newVal = slRect.y * ( max - min) / (height - slRect.height);
  	
  	if ( val != newVal ) {
  		val = newVal;
--- 509,517 ----
  	int newVal;
  	
  	if ( ori == HORIZONTAL )
! 		newVal = slRect.x * ( max - min) / (width - slRect.width ) +min;
  	else
! 		newVal = slRect.y * ( max - min) / (height - slRect.height) +min;
  	
  	if ( val != newVal ) {
  		val = newVal;
+--- Kero ------------------ kero at dds.nl ---+
| I ain't changed,                          |
| but I know I ain't the same               |
+--- M38C --- http://huizen.dds.nl/~kero ---+


More information about the kaffe mailing list