Question About Scrollbar

  • Thread starter Edward H. Fabrega
  • Start date
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());
}
}
 
A

Andrew Thompson

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

Same behaviour here, that is to indicate it has focus,
note that keyboard <-, -> work when it's in focus, and if
you 'tab' off it to a button, it stops blinking.

The scrollbar of the scrollpane, OTOH, does not gain keyboard
focus, you can move it with the mouse, but the keyboard has
no effect, and whatever button (or the other scrollbar)
retains focus.

Try 'tabbing' around your applet after clicking the top scrollbar.
The buttons gain, and thereafter retain, keyboard 'tab' focus.
..Here is the runnable code:

Nice example, BTW. Allowed me to look into it effortlessly.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
E

Edward H. Fabrega

Andrew Thompson said:
Same behaviour here, that is to indicate it has focus,
note that keyboard <-, -> work when it's in focus, and if
you 'tab' off it to a button, it stops blinking.

The scrollbar of the scrollpane, OTOH, does not gain keyboard
focus, you can move it with the mouse, but the keyboard has
no effect, and whatever button (or the other scrollbar)
retains focus.

Try 'tabbing' around your applet after clicking the top scrollbar.
The buttons gain, and thereafter retain, keyboard 'tab' focus.


Thanks for the info. The blinking scrollbar is just weird. I can't recall
ever running a real program where that effect happens. Just a dashed line
around the thumb would have been okay, or in the cases where it was too
small because of the size of the scrollable area just have it shaded in
without a blink, or just shade it in all the time when it had focus. I guess
this begs the question why doesn't the scrollpane scrollbar get keyboard
focus. Not that I'm complaining, because I'm not, but I'm curious why there
was a design difference between the standalone scrollbar and the one that's
part of the scrollpane.

Ed
 
M

marcus

Hmm -- "real program"
troll, or c# mole
Thanks for the info. The blinking scrollbar is just weird. I can't recall
ever running a real program where that effect happens. Just a dashed line
around the thumb would have been okay, or in the cases where it was too
small because of the size of the scrollable area just have it shaded in
without a blink, or just shade it in all the time when it had focus. I guess
this begs the question why doesn't the scrollpane scrollbar get keyboard
focus. Not that I'm complaining, because I'm not, but I'm curious why there
was a design difference between the standalone scrollbar and the one that's
part of the scrollpane.

Ed
 
E

Edward H. Fabrega

marcus said:
Hmm -- "real program"
troll, or c# mole

For your sake, I hope you were drunk when you accused me of being a "troll,
or a c# mole" If not, get some consipiracy treatment pronto. And a life.

Ed
 
C

Chris Uppal

Edward said:
For your sake, I hope you were drunk when you accused me of being a
"troll, or a c# mole"

I think he probably (mis)interpreted you to mean "real" program as opposed to
Java programs, rather than (as I read it, anyway) as opposed to applets.

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top