Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4040132

Scrollbar is sending extra events with single mouse clicks when event handler is

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1, 1.1.1
    • client-libs
    • None
    • sparc
    • solaris_2.5.1



      Name: sgC58550 Date: 03/19/97


      The attached code demonstrates the bug. When the event handler
      for a Motif Scrollbar takes a large amount of time to run, and
      the Scrollbar is sending UNIT_INCREMENT or UNIT_DECREMENT events,
      extra events are sometimes generated by the bar. Thus, single
      clicks on the scrollbar arrows will generate multiple scroll
      events. In some cases, a cascade of events will drive the
      scrollbar to the end.

      In my example, I use a sleep to simulate a large amount of
      processing by the event handler, but I am careful to space out
      my mouse clicks so that they do not arrive during a sleep.

      The problem occurs when the AWT window is running on the
      local machine, and also on a remote X server.

      I note that this bug is similar to 4028490, but it does not
      involve Win32, does not involve multiple clicks, and single
      spurious events can be generated instead of a cascade.


      Test case:


      import java.awt.*;
      import java.awt.event.*;
       
      public class MainTest extends Frame {
       
        public MainTest() {
       
          this.addWindowListener(
            new WindowAdapter() {
              public void windowClosing(WindowEvent event) {
                System.exit(0);
              }
            }
          );
       
          class MAL implements AdjustmentListener {
            public void adjustmentValueChanged(AdjustmentEvent e) {
              System.out.println("Scrollbar event " + count++ + " caught");
              Thread myThread = Thread.currentThread();
              try {
                myThread.sleep(400);
              } catch (InterruptedException x ) {
       
              }
              System.out.println("Done sleeping");
            }
          }
       
          Scrollbar myBar = new Scrollbar(Scrollbar.VERTICAL, 0, 6, 0, 80);
          myBar.setBlockIncrement(1);
          myBar.setUnitIncrement(1);
          this.add("East", myBar);
          myBar.addAdjustmentListener(new MAL());
        }
       
        public static void main(String args[]) {
          Frame f = new MainTest();
          f.setSize(500, 500);
          f.show();
        }
       
        private int count = 0;
      }


      company - Lembersky-Chi Inc. , email - ###@###.###
      ======================================================================

            xdengsunw Xianfa Deng (Inactive)
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: