-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.1.6, 1.2.0
-
generic, x86
-
generic, windows_nt
Name: abC81024 Date: 12/26/98
If we change the ScrollPane size or the ScrollPane child component size then
the java.awt.ScrollPane class getInsets method returns insets for previous
state of the ScrollPane and the ScrollPane child component.
to reproduce
1. compile and run TestCase.java
2. notice, that ScrollPane have scrollbars
3. press the button in ScrollPane for retrieve the insets and notice that insets
fields "right" and "bottom" equals 2 - it means we haven't scrollbars.
4. increase the size of window and retrieve the insets against. notice that
the insets fields "right" and "bottom" equals 18 - it means we have scrollbars.
=== TestCase.java ===
import java.awt.*;
import java.awt.event.*;
class TestCase extends Frame {
static final int virtXsize = 200;
static final int virtYsize = 200;
ActionListener listener;
ScrollPane pane;
Button button;
TextField field;
public TestCase() {
field = new TextField();
pane = new ScrollPane();
listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Insets res = pane.getInsets();
System.out.println("Retrieve insets: " + res);
String label = "top="+res.top+",left="+res.left+",bottom="+res.bottom+",right="+res.right;
field.setText(label);
}
};
button = new Button("Get Insets") {
public Dimension getPreferredSize() {
return new Dimension(virtXsize,virtYsize);
}
};
button.addActionListener(listener);
pane.add(button);
setLayout(new BorderLayout());
add(pane);
add(field,"South");
Adjustable adj = pane.getVAdjustable();
adj.setUnitIncrement(20);
}
public static void main(String[] args) {
TestCase tc = new TestCase();
tc.setTitle("ScrollPane insets bug");
tc.setSize(190,190);
System.out.println("Show window!");
tc.setVisible(true);
}
};
=====================
======================================================================