E
Edward H. Fabrega
I have a Scrollbar in an applet that starts blinking when I activate it in
any way (clicking on the thumb, clicking the scrollbar arrows, or clicking
in the scrollbar not on the thumb). Aside from the blinking the scrollbar
works fine. Since my Java book doesn't mention this I'm thinking that the
blinking could be related to the OS (XP Pro SP2). There is a scrollpane in
the applet that works fine and doesn't blink. I'm curious as to why this is
happening. I don't know how a scrollbar is painted or where it gets painted,
and I'm 99.999 percent sure that I'll use scrollpanes (especially now), but
I'd still like to know why the scrollbar is blinking. I can deal with "it's
some kind of bad magic in the peer interface", but just in case this is a
"doh!" kind of happenstance I'm asking for an explanation. Here is the
runnable code:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class AdjustmentTest extends Applet {
private ScrollPane scroller = new ScrollPane();
private Scrollbar sbar = new Scrollbar(Scrollbar.HORIZONTAL);
public void init() {
setLayout(new BorderLayout());
sbar.setValues(0, // value
50, // visible
0, // minimum
100 // maximum
);
sbar.setUnitIncrement (10);
sbar.setBlockIncrement(20);
add(sbar, "North");
scroller.add(new ScrollMe(), 0);
add(scroller, "Center");
sbar.addAdjustmentListener(
new DebugAdjustmentListener());
scroller.getHAdjustable().addAdjustmentListener(
new DebugAdjustmentListener());
scroller.getVAdjustable().addAdjustmentListener(
new DebugAdjustmentListener());
}
}
class ScrollMe extends Panel {
public ScrollMe() {
for(int i=0; i < 25; ++i)
add(new Button("Button " + i));
}
}
class DebugAdjustmentListener implements AdjustmentListener {
public void adjustmentValueChanged(AdjustmentEvent event) {
Object obj = event.getSource();
System.out.println(obj.toString());
}
}
any way (clicking on the thumb, clicking the scrollbar arrows, or clicking
in the scrollbar not on the thumb). Aside from the blinking the scrollbar
works fine. Since my Java book doesn't mention this I'm thinking that the
blinking could be related to the OS (XP Pro SP2). There is a scrollpane in
the applet that works fine and doesn't blink. I'm curious as to why this is
happening. I don't know how a scrollbar is painted or where it gets painted,
and I'm 99.999 percent sure that I'll use scrollpanes (especially now), but
I'd still like to know why the scrollbar is blinking. I can deal with "it's
some kind of bad magic in the peer interface", but just in case this is a
"doh!" kind of happenstance I'm asking for an explanation. Here is the
runnable code:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class AdjustmentTest extends Applet {
private ScrollPane scroller = new ScrollPane();
private Scrollbar sbar = new Scrollbar(Scrollbar.HORIZONTAL);
public void init() {
setLayout(new BorderLayout());
sbar.setValues(0, // value
50, // visible
0, // minimum
100 // maximum
);
sbar.setUnitIncrement (10);
sbar.setBlockIncrement(20);
add(sbar, "North");
scroller.add(new ScrollMe(), 0);
add(scroller, "Center");
sbar.addAdjustmentListener(
new DebugAdjustmentListener());
scroller.getHAdjustable().addAdjustmentListener(
new DebugAdjustmentListener());
scroller.getVAdjustable().addAdjustmentListener(
new DebugAdjustmentListener());
}
}
class ScrollMe extends Panel {
public ScrollMe() {
for(int i=0; i < 25; ++i)
add(new Button("Button " + i));
}
}
class DebugAdjustmentListener implements AdjustmentListener {
public void adjustmentValueChanged(AdjustmentEvent event) {
Object obj = event.getSource();
System.out.println(obj.toString());
}
}