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

Focus and MouseEvent problems with Scrollbar

XMLWordPrintable

    • b37
    • generic, x86, sparc
    • generic, solaris_8, solaris_9, windows_2000

      ====================================================================
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b83)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b83, mixed mode)

      =======================================================================
      Platforms : Windows NT,Me, Solaris Sparc 2.9/IA


      1) On Windows When you click on a Scroll bar with the Left Mouse Button ,
      keyReleased and keyClicked events are not generated .These keyevents are generated for the Right mouse button and this problem is specific to LeftMouse Button .

      On Solaris Sparc/IA no keyevents are generated for Left as well as Right mouse
      button.

      (Please use ScrollBarTest.java for to reproduce the above mentioned problem )


      2) When you click on the ScrollBar with the left mouse, and then when
      you use the down key , you will observe that keyEvents are not delivered to the
      ScrollBar. Hence you will not be able to scroll down using the down key .
      On Solaris this works fine and keyevents are delivered to the scroll bar
      once the focus is on the scroll bar .

      (Please use ScrollBarTest1.java for the second problem )


      A similar bug was raised for Kestrel .Please refer to bug 4318862 .The
      state of this bug is verified in Merlin-beta . But this problem still seems to exist with JDK 1.4 .

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

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


      public class ScrollBarTest implements KeyListener,MouseListener,AdjustmentListener{

              Frame frame;
              Scrollbar scrollBar ;
              Button button ;

          public ScrollBarTest() {

              frame=new Frame();
              frame.setTitle("Scroll Bar Test");
              frame.setLayout(new FlowLayout());

              scrollBar = new Scrollbar(Scrollbar.VERTICAL, 0, 60, 0, 400);
              button = new Button("Button");
              scrollBar.addAdjustmentListener(this);
              scrollBar.addKeyListener(this);
              scrollBar.addMouseListener(this);
              frame.add(button);
              frame.add(scrollBar);

              frame.setBackground(Color.red);
              frame.setSize(500,200);
              frame.setVisible(true);
              frame.toFront();
          }

          public void actionPerformed(ActionEvent ae) {
             System.out.println("in actionPerformed ");

          }
          public void keyPressed(KeyEvent e ){
             System.out.println("in keyPressed");
          }
           public void keyReleased(KeyEvent e ){
             System.out.println("in keyReleased");
          }

          public void keyTyped(KeyEvent e ){
             System.out.println("in keyTyped");
          }
          public void mousePressed(MouseEvent e ){
             System.out.println("in mouse Pressed");
          }
          public void mouseClicked(MouseEvent e ){
             System.out.println("in mouse Clicked");
          }
         public void mouseReleased(MouseEvent e ){
             System.out.println("in mouse Released");
          }
           public void mouseExited(MouseEvent e ){
             System.out.println("in mouse exited");
          }
           public void mouseEntered(MouseEvent e ){
             System.out.println("in mouse Entered");
          }

          public void adjustmentValueChanged(AdjustmentEvent e){
            System.out.println("adjustment listerner called ");
            //System.out.println("adjustment value is :"+ e.getValue());
            //System.out.println("isValue adjusting :"+e.getValueIsAdjusting());
          }

      public static void main(String args[]){
        ScrollBarTest avt = new ScrollBarTest();

       }
      }
      ================================================================================


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

      public class ScrollBarTest1 extends Frame implements AdjustmentListener ,KeyListener {

          public ScrollBarTest1() {
      Scrollbar scrollbar = new Scrollbar(Scrollbar.VERTICAL,0, 1, 0, 255);
      add("East", scrollbar);
      scrollbar.addAdjustmentListener(this);
              scrollbar.addKeyListener(this);
          }

          public void adjustmentValueChanged(AdjustmentEvent e) {
      System.out.println("Adjustment Event called ");
          }

          public void keyPressed(KeyEvent e) {
            System.out.println("KeyPressed called");
          }

          public void keyReleased(KeyEvent e ){
             System.out.println("in keyReleased");
          }

          public void keyTyped(KeyEvent e ){
             System.out.println("in keyTyped");
          }

           public static void main(String argv[]) {
      ScrollBarTest1 scrollBarTest = new ScrollBarTest1();
              scrollBarTest.setBackground(Color.red);
              scrollBarTest.setSize(500,200);
              scrollBarTest.setVisible(true);
              scrollBarTest.toFront();
          }

      }
      ===============================================================================

      In #1 , the problem is for Mouse Events and not keyEvents . It was a typo .
      ###@###.### 2001-10-17

            ant Anton Tarasov (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: