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

MouseEvents on a scroll bar are inconsistent between mouse buttons.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4, 1.1.5, 1.2.0
    • client-libs
    • generic, x86
    • generic, windows_95, windows_nt



      Name: joT67522 Date: 10/22/97


      The MouseEvents that get fired by clicking on a Scrollbar seem to be as follows:

      Left Button: MOUSE_PRESSED
      Right Button: MOUSE_PRESSED, MOUSE_CLICKED, MOUSE_RELEASED

      I found this out by putting a System.out.println(event) in each of the MouseListener
      methods, where event is a MouseEvent.

      I wanted to determine when the user has let go of the scroll bar bubble after performing
      a TRACK adjustment, in an attempt to allow tracking while disabling the "live" tracking
      -- like the scrollbar worked in older mac os's. This is necessary becuase the scrollbar
      value controls what page of data in a listbox to display. With the "live" tracking, the
      listbox is too slow with its updates.



      Just click on the scrollbar with the right and then the
      left button and watch your console window.


      import java.awt.*;
      import java.awt.event.*;

      class ButtonTest extends Frame implements AdjustmentListener,
      MouseListener
      {
          public ButtonTest()
          {
              super("blah");
              BorderLayout layout = new BorderLayout();
              setLayout(layout);

              turnPage = new Scrollbar(Scrollbar.HORIZONTAL);
              List someList = new List(15);
              Panel middle = new Panel(new BorderLayout());
              middle.add("North", someList);
              middle.add("South", turnPage);
              add("Center", middle);

              turnPage.addAdjustmentListener(this);
              turnPage.addMouseListener(this);

              turnPage.setValues(0, 1, 0, 15);

              pack();
          }

          public static void main(String argv[]) {
      ButtonTest bt = new ButtonTest();
      bt.setVisible(true);
      }


          public void adjustmentValueChanged(AdjustmentEvent event)
          {

          }

          public void mouseClicked(MouseEvent event){
              System.out.println(event);
          }

          public void mouseEntered(MouseEvent event){
              System.out.println(event);
          }

          public void mouseExited(MouseEvent event){
              System.out.println(event);
          }

          public void mousePressed(MouseEvent event){
              System.out.println(event);
          }

          public void mouseReleased(MouseEvent event){
              System.out.println(event);
          }

          private Scrollbar turnPage;
      }


      ======================================================================

            mmartaksunw Michael Martak (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: