Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4075484
Votes 19
Synopsis ScrollPane's adjustables only generate TRACK Adjustment Events
Category java:classes_awt
Reported Against 1.1.3 , kestrel-beta
Release Fixed 1.5(tiger)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 29-AUG-1997
Description




Run the code, watch the output.
No matter what is clicked on the scrollbar, only one Adjustment
Event type is generated - TRACK. There is never UNIT_* event
nor BLOCK_* generated.

import java.awt.*;
import java.awt.event.*;
 
public class MyFrame extends Frame
{
        ScrollPane pane;
        class comp extends Component {
 
                public comp(){}
                public Dimension getPreferredSize() {
                        return new Dimension(400,400);
                }
        }
        class AdjustmentAdapter implements AdjustmentListener {
                public void adjustmentValueChanged(AdjustmentEvent e){}
        }
 
    AdjustmentAdapter adjustmentListener = new AdjustmentAdapter () {
            /**
             * Scrolls the column or row header depending on which scrollbar
             * in the scrollPane was clicked
             */
            public void adjustmentValueChanged(AdjustmentEvent e) {
            if (e.getAdjustmentType() == AdjustmentEvent.BLOCK_DECREMENT)
                System.out.println("BLOCK_DECREMENT");
            else if (e.getAdjustmentType() == AdjustmentEvent.BLOCK_INCREMENT)
                System.out.println("BLOCK_INCREMENT");
            else if (e.getAdjustmentType() == AdjustmentEvent.UNIT_DECREMENT)
                System.out.println("UNIT_DECREMENT");
            else if (e.getAdjustmentType() == AdjustmentEvent.UNIT_INCREMENT)
                System.out.println("UNIT_INCREMENT");
            else if (e.getAdjustmentType() == AdjustmentEvent.TRACK)
                System.out.println("TRACK");
            }
        };
 
 
 
 
        public  MyFrame() {
                super();
                add(pane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED));
                pane.add(new comp());
        pane.getHAdjustable().addAdjustmentListener(adjustmentListener);
        pane.getVAdjustable().addAdjustmentListener(adjustmentListener);
        }
 
        public static void main(String [] args) {
                MyFrame f = new MyFrame();
                f.setSize(200,200);
                f.setVisible(true);
        }
}


======================================================================
Work Around




NONE
======================================================================
Evaluation
Problem reproducible with JDK1.1.5.

  xxxxx@xxxxx   1997-11-23
=======================================================================
The bug is still reproducible with JDK 1.3RA under Sun4 Solaris 2.7.

  xxxxx@xxxxx   1999-12-15




When user scroll ScrollPane, we receive notifications in native code. Then we propogate
these notifications to Java code by issuing PeerEvent which calls setValue() with
new scrolling position on appropriate adjustable. ScrollPaneAdjustable.setValue() 
fires AdjustmentEvent for this change. The problem is that there is no way to pass 
scroll-type to setValue()(we can use only public api from peers, and setValue() only
accepts 'int position') so it always fires AdjustmentEvent.TRACK.

This happend for both Solaris and Windows as the code is absolutely the same.

Note that for Scrollbar we fire AdjustmentEvent from the peer so we not the 
scroll-type. Unfortunately, we can't setValue() for ScrollPane because it will
be very incompatible change.
  xxxxx@xxxxx   2002-07-25

======================================================================
Comments
  
  Include a link with my name & email   

Submitted On 25-MAY-1999
achace
1.2 still has this problem. Can't be *that* hard to fix.


Submitted On 23-MAY-2001
gdipierro
Sounds like the same problem as in 4139140. I'm glad 
someone has finally admitted that it is a bug!


Submitted On 19-JUN-2001
abcdefg2
I would really like to know what to do about this because I 
would really like to be able to use the UNIT_* Events. Is 
there no other way to listen to those buttons on the 
jscrollbar or should I just create my own buttons?  How can 
there be a bug and no one tries to solve it?


Submitted On 27-JUN-2002
pkhoosh
The bug is still reproducible with JDK 1.4


Submitted On 01-JUL-2002
r_rajin
this bug still exists in jdk1.4


Submitted On 16-JUL-2002
pettaspagna
I found the same bug and sent a mail to someone else. Lots of people 
observe that this is a bug, and I experienced the same bug with a similar 
code. This is a bug to be fixed!


Submitted On 27-JUN-2008
keenoar
This bug is not fixed yet. I have it in 1.6.0



PLEASE NOTE: JDK6 is formerly known as Project Mustang