home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / plaf / basic / BasicTreeUI$TreeScrollLRAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  2.0 KB  |  49 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.Rectangle;
  4. import java.awt.event.ActionEvent;
  5. import javax.swing.AbstractAction;
  6. import javax.swing.tree.TreePath;
  7.  
  8. class BasicTreeUI$TreeScrollLRAction extends AbstractAction {
  9.    // $FF: synthetic field
  10.    private final BasicTreeUI this$0;
  11.    protected int direction;
  12.    private boolean addToSelection;
  13.  
  14.    public BasicTreeUI$TreeScrollLRAction(BasicTreeUI var1, int var2, String var3, boolean var4) {
  15.       super(var3);
  16.       this.this$0 = var1;
  17.       this.direction = var2;
  18.       this.addToSelection = var4;
  19.    }
  20.  
  21.    public void actionPerformed(ActionEvent var1) {
  22.       if (this.this$0.tree != null && this.this$0.getRowCount(this.this$0.tree) > 0 && this.this$0.treeSelectionModel != null) {
  23.          Rectangle var4 = this.this$0.tree.getVisibleRect();
  24.          TreePath var3;
  25.          if (this.direction == -1) {
  26.             var3 = this.this$0.getClosestPathForLocation(this.this$0.tree, var4.x, var4.y);
  27.             var4.x = Math.max(0, var4.x - var4.width);
  28.          } else {
  29.             var4.x = Math.min(Math.max(0, this.this$0.tree.getWidth() - var4.width), var4.x + var4.width);
  30.             var3 = this.this$0.getClosestPathForLocation(this.this$0.tree, var4.x, var4.y + var4.height);
  31.          }
  32.  
  33.          this.this$0.tree.scrollRectToVisible(var4);
  34.          if (this.addToSelection) {
  35.             BasicTreeUI.access$7(this.this$0, var3);
  36.          } else if (BasicTreeUI.access$8(this.this$0)) {
  37.             this.this$0.tree.setSelectionPath(var3);
  38.          } else {
  39.             BasicTreeUI.access$6(this.this$0, var3, true);
  40.          }
  41.       }
  42.  
  43.    }
  44.  
  45.    public boolean isEnabled() {
  46.       return this.this$0.tree != null && this.this$0.tree.isEnabled();
  47.    }
  48. }
  49.