Question About Scrollbar

Discussion in 'Java' started by Edward H. Fabrega, Oct 7, 2004.

  1. 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());
    }
    }
     
    Edward H. Fabrega, Oct 7, 2004
    #1
    1. Advertising

  2. On Wed, 6 Oct 2004 22:01:37 -0700, Edward H. Fabrega wrote:

    > 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
     
    Andrew Thompson, Oct 7, 2004
    #2
    1. Advertising

  3. "Andrew Thompson" <> wrote in message
    news:cdo1y5x50ugx.2qel1e3qpmna$...
    > On Wed, 6 Oct 2004 22:01:37 -0700, Edward H. Fabrega wrote:
    >
    >> 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.



    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
     
    Edward H. Fabrega, Oct 8, 2004
    #3
  4. Edward H. Fabrega

    marcus Guest

    Hmm -- "real program"
    troll, or c# mole

    Edward H. Fabrega wrote:
    > "Andrew Thompson" <> wrote in message
    > news:cdo1y5x50ugx.2qel1e3qpmna$...
    >
    >>On Wed, 6 Oct 2004 22:01:37 -0700, Edward H. Fabrega wrote:
    >>
    >>
    >>>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.

    >
    >
    >
    > 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
    >
    >
     
    marcus, Oct 8, 2004
    #4
  5. "marcus" <> wrote in message
    news:...
    > 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
     
    Edward H. Fabrega, Oct 10, 2004
    #5
  6. Edward H. Fabrega

    Chris Uppal Guest

    Edward H. Fabrega wrote:
    > "marcus" <> wrote:
    > > 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"


    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
     
    Chris Uppal, Oct 10, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    340
  2. Mike Novak

    MSIE and scrollbar question

    Mike Novak, Jul 3, 2003, in forum: HTML
    Replies:
    1
    Views:
    420
  3. Replies:
    3
    Views:
    410
    dorayme
    Apr 16, 2006
  4. Michael Weis
    Replies:
    13
    Views:
    1,002
    Michael Weis
    Aug 12, 2006
  5. Alex

    ScrollBar? Does it exist just WEB ScrollBar Control?

    Alex, Apr 1, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    273
    Alvin Bruney [MVP]
    Apr 4, 2004
Loading...

Share This Page