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)
======================================================================