home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / plaf / basic / BasicTreeUI$TreePageAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  2.6 KB  |  65 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.AbstractAction;
  4. import java.awt.Dimension;
  5. import java.awt.Rectangle;
  6. import java.awt.event.ActionEvent;
  7. import java.io.Serializable;
  8.  
  9. class BasicTreeUI$TreePageAction extends AbstractAction implements Serializable {
  10.    // $FF: synthetic field
  11.    private final BasicTreeUI this$0;
  12.    private int direction;
  13.  
  14.    public BasicTreeUI$TreePageAction(BasicTreeUI var1, int var2, String var3) {
  15.       super(var3);
  16.       this.this$0 = var1;
  17.       this.this$0 = var1;
  18.       this.direction = var2;
  19.    }
  20.  
  21.    public void actionPerformed(ActionEvent var1) {
  22.       if (this.this$0.tree != null && this.this$0.getRowCount() > 0 && this.this$0.treeSelectionModel != null) {
  23.          Dimension var3 = this.this$0.tree.getSize();
  24.          Rectangle var7 = this.this$0.tree.getVisibleRect();
  25.          int var8 = Math.max(0, var3.height - var7.height);
  26.          int var5;
  27.          if (this.direction == -1) {
  28.             var5 = this.this$0.getMinSelectionRow();
  29.          } else {
  30.             var5 = this.this$0.getMaxSelectionRow();
  31.          }
  32.  
  33.          if (var5 != -1) {
  34.             Rectangle var6 = this.this$0.getRowBounds(var5);
  35.             if (this.direction == -1) {
  36.                var7.y = Math.max(0, var6.y + var6.height - var7.height);
  37.             } else {
  38.                var7.y = Math.min(var8, var6.y);
  39.             }
  40.          } else {
  41.             var7.y = Math.min(var8, var7.y + var7.height * this.direction);
  42.          }
  43.  
  44.          int var4;
  45.          if (this.direction == 1) {
  46.             var4 = this.this$0.getClosestRowForLocation(var7.x, var7.y + var7.height - 1);
  47.             Rectangle var9 = this.this$0.getRowBounds(var4);
  48.             var7.y = Math.min(var8, var9.y + var9.height - var7.height);
  49.          } else {
  50.             var4 = this.this$0.getClosestRowForLocation(var7.x, var7.y + 1);
  51.             Rectangle var10 = this.this$0.getRowBounds(var4);
  52.             var7.y = Math.min(var8, var10.y);
  53.          }
  54.  
  55.          this.this$0.tree.scrollRectToVisible(var7);
  56.          this.this$0.tree.setSelectionRow(var4);
  57.       }
  58.  
  59.    }
  60.  
  61.    public boolean isEnabled() {
  62.       return this.this$0.tree != null && this.this$0.tree.isEnabled();
  63.    }
  64. }
  65.