United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4098739 : JDK 1.1.5 Scrollbar maximum value behavior differs from API

Details
Type:
Bug
Submit Date:
1997-12-11
Status:
Closed
Updated Date:
1998-01-05
Project Name:
JDK
Resolved Date:
1998-01-05
Component:
docs
OS:
solaris_2.5.1
Sub-Component:
guides
CPU:
sparc
Priority:
P3
Resolution:
Duplicate
Affected Versions:
1.1.5
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description

Name: joT67522			Date: 12/11/97


There seems to be a long-standing bug in the
Solaris implementation of the JDK 1.1.x Scrollbar
class.  According to the API documentation, if
you create a scrollbar with the specification:
   minimum = 0
   visible = 64
   maximum = 255
then the resulting scrollbar should have a track
of length 255+64, a slider of length 64, and a
maximum value of 255.  This is precisely the
example given in the API documentation.  I have
written a small applet to test this (see the
Scrolltest class below.)  On all of the browsers
and platforms I have tested (Solaris, Win95,
WinNT, and Mac, with Netscape and MSIE), this is
the behavior I see.

However, on Solaris, when I run the same applet
with the JDK 1.1.5 appletviewer I get a scrollbar
whose maximum value is 191 (255-64.)  This
disagrees with the behavior specified in the API
documentation.

Below is both the source code for the small
applet, and a sample HTML file that can be used
to load it.


Here is the HTML file:

<html>
<head><title>Scrollbar Test</title>
</head>
<body bgcolor=#ffffff>
<h1>Scrollbar Test</h1>
<br>
<applet code="Scrolltest" width=350	height=350 align=top>
Could not display applet.
</applet>
</body>
</html>


Here is the code:

// Scrolltest

// This class just puts up a simple scrollbar.  It was written to test
// the differences in the interpretation of the "maximum" parameter
// between different JDK's & browsers.

import java.awt.*;
import java.applet.*;

public class Scrolltest extends Applet {
	private static int MINIMUM = 0;
	private static int VISIBLE = 64;
	private static int MAXIMUM = 255;

	private Scrollbar sbar = new Scrollbar(Scrollbar.VERTICAL, 0,
																				 VISIBLE, MINIMUM, MAXIMUM);
	private TextField sval = new TextField(50);

	public void init() {
		setLayout(new BorderLayout());
		Panel specPanel = new Panel();
		specPanel.setLayout(new FlowLayout());
		specPanel.add(new Label("Minimum: " + MINIMUM));
		specPanel.add(new Label("Visible: " + VISIBLE));
		specPanel.add(new Label("Maximum: " + MAXIMUM));
		add("Center", specPanel);
		add("East", sbar);
		sval.setText("Current value = " + sbar.getValue());
		add("South", sval);
	}

	public boolean handleEvent(Event e) {
		if (e.target == sbar) {
			sval.setText("Current value = " + sbar.getValue());
		}
		return super.handleEvent(e);
	}

}
(Review ID: 21798)
======================================================================

                                    

Comments
WORK AROUND



Name: joT67522			Date: 12/11/97


Make your own scrollbar class.  I suggest
subclassing Panel, and putting an awt Scrollbar
in the Panel.  You can detect the prescence of the
bug by attempting to set the value of the
scrollbar to the maximum.  If this fails, then
the bug exists and you can adjust the maximum
value to take it into account.
======================================================================
                                     
2004-06-11



Hardware and Software, Engineered to Work Together