home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / SampleTree$AddAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  1.9 KB  |  34 lines

  1. import com.sun.java.swing.tree.DefaultMutableTreeNode;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4.  
  5. class SampleTree$AddAction implements ActionListener {
  6.    // $FF: synthetic field
  7.    private final SampleTree this$0;
  8.    public int addCount;
  9.  
  10.    public void actionPerformed(ActionEvent var1) {
  11.       DefaultMutableTreeNode var3 = this.this$0.getSelectedNode();
  12.       DefaultMutableTreeNode var4;
  13.       if (var3 != null) {
  14.          var4 = (DefaultMutableTreeNode)var3.getParent();
  15.       } else {
  16.          var4 = (DefaultMutableTreeNode)this.this$0.treeModel.getRoot();
  17.       }
  18.  
  19.       int var2;
  20.       if (var3 == null) {
  21.          var2 = this.this$0.treeModel.getChildCount(var4);
  22.       } else {
  23.          var2 = var4.getIndex(var3) + 1;
  24.       }
  25.  
  26.       this.this$0.treeModel.insertNodeInto(this.this$0.createNewNode("Added " + Integer.toString(this.addCount++)), var4, var2);
  27.    }
  28.  
  29.    SampleTree$AddAction(SampleTree var1) {
  30.       this.this$0 = var1;
  31.       this.this$0 = var1;
  32.    }
  33. }
  34.