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

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import javax.swing.ListSelectionModel;
  5.  
  6. class BasicListUI$IncrementLeadSelectionAction extends BasicListUI.ListAction {
  7.    // $FF: synthetic field
  8.    private final BasicListUI this$0;
  9.    protected int amount;
  10.    protected int selectionType;
  11.  
  12.    protected BasicListUI$IncrementLeadSelectionAction(BasicListUI var1, String var2, int var3) {
  13.       this(var1, var2, var3, -1);
  14.    }
  15.  
  16.    protected BasicListUI$IncrementLeadSelectionAction(BasicListUI var1, String var2, int var3, int var4) {
  17.       super(var1, var2);
  18.       this.this$0 = var1;
  19.       this.amount = var4;
  20.       this.selectionType = var3;
  21.    }
  22.  
  23.    public void actionPerformed(ActionEvent var1) {
  24.       int var2 = this.getNextIndex();
  25.       if (var2 >= 0 && var2 < this.this$0.list.getModel().getSize()) {
  26.          ListSelectionModel var3 = this.this$0.list.getSelectionModel();
  27.          if (this.selectionType == 2) {
  28.             int var4 = var3.getAnchorSelectionIndex();
  29.             if (var4 == -1) {
  30.                var4 = var2;
  31.             }
  32.  
  33.             this.this$0.list.setSelectionInterval(var4, var2);
  34.             var3.setAnchorSelectionIndex(var4);
  35.             var3.setLeadSelectionIndex(var2);
  36.          } else if (this.selectionType == 1) {
  37.             this.this$0.list.setSelectedIndex(var2);
  38.          } else {
  39.             var3.setLeadSelectionIndex(var2);
  40.          }
  41.  
  42.          this.ensureIndexIsVisible(var2);
  43.       }
  44.  
  45.    }
  46.  
  47.    protected void ensureIndexIsVisible(int var1) {
  48.       this.this$0.list.ensureIndexIsVisible(var1);
  49.    }
  50.  
  51.    protected int getNextIndex() {
  52.       int var1 = this.this$0.list.getLeadSelectionIndex();
  53.       int var2 = this.this$0.list.getModel().getSize();
  54.       if (var1 == -1) {
  55.          if (var2 > 0) {
  56.             if (this.amount > 0) {
  57.                var1 = 0;
  58.             } else {
  59.                var1 = var2 - 1;
  60.             }
  61.          }
  62.       } else {
  63.          var1 += this.amount;
  64.       }
  65.  
  66.       return var1;
  67.    }
  68. }
  69.