DeleteFileDialog.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:2k
源码类别:

SNMP编程

开发平台:

C/C++

  1. /* $Id: DeleteFileDialog.java,v 1.3 2002/09/09 05:46:50 parasuraman Exp $ */
  2. /*
  3.  * @(#)CreateDirDialog.java
  4.  * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
  5.  * Please read the associated COPYRIGHTS file for more details.
  6.  */
  7. import java.applet.*;
  8. import java.io.*;
  9. import java.awt.*;
  10. import java.util.*;
  11. import com.adventnet.snmp.snmp2.SASClient;
  12. public class DeleteFileDialog extends Applet {
  13.  Label label ;
  14.  TextField textfield;
  15.   ButtonPanel ok_close =null;
  16.   public SASClient sframe; // The frame that provides the OK function
  17.   Font fontb = new Font("Helvetica", Font.BOLD, 16);
  18.   Font font = new Font("Helvetica", Font.PLAIN, 16);
  19.   String advent = new String("AdventNet Delete File Dialog");
  20. /* This takes care of the look of CreateDirDialog */
  21.   public void init() { 
  22.   try{
  23.   
  24.   sframe = new SASClient(this,false,2);}
  25.   catch(Exception e){}
  26.     //sframe.protocol = 2;
  27.   setBackground(Color.lightGray);
  28.     setLayout(new BorderLayout());
  29. label = new Label("File Name to be Deleted");
  30.     textfield = new TextField(40);  
  31. setLayout(new FlowLayout(FlowLayout.LEFT));
  32.     add(label);
  33.     add(textfield);
  34.     String buttons[] = {"OK","Cancel"};
  35.     ok_close = new ButtonPanel(buttons);
  36.     add("South", ok_close);
  37.     resize(550,200);
  38.   }
  39.   boolean loading = false;  // to avoid loading MIBs twice
  40. /* for OK and CANCEL actions */
  41.   public boolean action(Event e, Object arg) {
  42. if (e.target instanceof Button) {
  43.             //if (arg.equals("Cancel")) this.hide();
  44.             //else 
  45. if (arg.equals("OK")) {
  46. loading = true;
  47. try{
  48. String filename = (new File(textfield.getText())).getName(); // get rid of path
  49. //File f = new File("HTTPUsers"+File.separator+filename);
  50. //sframe.deleteFile(f.getAbsolutePath());
  51. sframe.deleteFile(filename);
  52. }
  53. catch(Exception ex){
  54. //ex.printStackTrace();
  55. }
  56.     }
  57.         }
  58.     return true;
  59.   }
  60. /** Allow another MIB load only if shown again */
  61.   public synchronized void show() {
  62.     loading = false;
  63.     super.show();
  64.   }
  65.   /** To handle destroy window - pass all else to parent */
  66.   public boolean handleEvent(Event e) {
  67.     if (e.id == Event.WINDOW_DESTROY) {
  68. hide();
  69.     }
  70.     return super.handleEvent(e);
  71.   }
  72. }