Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2019211 | 1.2.0 | Konstantin Boudnik | P4 | Resolved | Fixed | 1.2fcs |
Name: vuC71690 Date: 02/23/98
uwe@russia
On win32 when setValues is called on disabled scrollbar, win32 call to
SetScrollInfo will enable the peer scrollbar if the scrollbar's new
parameters make the scrollbar necessary. And vice versa, when values
are set on enabled scrollbar that make scrollbar unnecessary,
SetScrollInfo will disable the peer.
Unfortunately, API spec does not describe how setValues affect enabled
status of the scrollbar.
A small test follows. Click buttons and watch the actual status of
scrollbar and the status of java control reported in a message.
Offending sequences are:
1. Disable, Set Random Values
Scrollbar becomes enabled, but java reports it's disabled.
2. Enable, Make All Visible
Scrollbar becomes disabled, but java reports it's enabled.
------------ DisabledScrollbar.java
import java.awt.*;
import java.awt.event.*;
class DisabledScrollbar extends Frame {
int sbMin, sbMax;
Scrollbar sb;
Label text;
Button enableButton, disableButton, setButton, maxButton;
public DisabledScrollbar(int min, int max) {
super("setValues can enable/disable your scrollbars...");
setLayout(new BorderLayout());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
text = new Label();
text.setAlignment(Label.CENTER);
add(text, BorderLayout.CENTER);
sbMin = min;
sbMax = max;
sb = new Scrollbar(Scrollbar.HORIZONTAL,
getRandomValue(), getRandomVisible(),
sbMin, sbMax);
sb.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
updateStatus();
}
});
add(sb, BorderLayout.NORTH);
Panel buttons = new Panel(new FlowLayout(FlowLayout.CENTER));
enableButton = new Button("Enable");
enableButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sbSetEnabled(true);
}
});
disableButton = new Button("Disable");
disableButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sbSetEnabled(false);
}
});
setButton = new Button("Set Random Values");
setButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sbSetValues(getRandomValue(), getRandomVisible(), sbMin, sbMax);
}
});
maxButton = new Button("Make All Visible");
maxButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sbSetValues(sbMin, sbMax, sbMin, sbMax);
}
});
buttons.add(enableButton);
buttons.add(disableButton);
buttons.add(setButton);
buttons.add(maxButton);
add(buttons, BorderLayout.SOUTH);
updateStatus();
pack();
show();
}
private void updateStatus() {
StringBuffer buf = new StringBuffer("Scrollbar is ");
buf.append(sb.isEnabled() ? "ENABLED" : "DISABLED");
int beg = sb.getValue();
int end = beg + sb.getVisibleAmount();
buf.append(" [" + beg + "," + end +"]");
buf.append(" of [" + sb.getMinimum() + "," + sb.getMaximum() + "]");
text.setText(buf.toString());
}
private void sbSetValues(int val, int vis, int min, int max) {
sb.setValues(val, vis, min, max);
updateStatus();
}
private void sbSetEnabled(boolean state) {
sb.setEnabled(state);
updateStatus();
}
public int getRandomValue() {
return sbMin + (int) (Math.random() * (sbMax - sbMin) / 2);
}
public int getRandomVisible() {
return (int) (Math.random() * (sbMax - sbMin) / 2);
}
public static void main(String[] args) {
int min = 0;
int max = 255;
if (args.length == 0) {
// just use defaults
}
else if (args.length == 2) {
try {
min = Integer.parseInt(args[0]);
max = Integer.parseInt(args[1]);
}
catch (NumberFormatException e) {
System.out.println(e.toString());
System.exit(1);
}
}
else {
System.out.println("Usage: DisabledScrollbar [min max]");
System.exit(1);
}
if (min >= max) {
System.out.println("Bad arguments: min >= max");
System.exit(1);
}
new DisabledScrollbar(min, max);
}
}
---------- end of DisabledScrollbar.java
======================================================================
- backported by
-
JDK-2019211 Scrollbar.setValues can enable or disable peer silently (win32)
-
- Resolved
-
- duplicates
-
JDK-4072398 Scrollbar peer is enabled erroneously, when the Scrollbar still thinks
-
- Closed
-