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

ScrollPane's adjustables only generate TRACK Adjustment Events

XMLWordPrintable

    • tiger
    • sparc
    • solaris_2.5.1, solaris_2.6



      Name: ggC50526 Date: 08/29/97


      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);
              }
      }

      company - AT&T , email - ###@###.###
      ======================================================================

            dmikhalksunw Denis Mikhalkin (Inactive)
            ggrahamsunw Gregory Graham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: