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

SNMP编程

开发平台:

C/C++

  1. /* $Id: SnmpGetApplet.java,v 1.1 2002/06/15 14:43:56 ram Exp $ */
  2. /* SnmpGetApplet.java
  3.  * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
  4.  * Please read the associated COPYRIGHTS file for more details.
  5.  */
  6. import java.applet.*;
  7. import javax.swing.*;
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. import com.adventnet.snmp.beans.*;
  11. import com.adventnet.snmp.ui.*;
  12. public class SnmpGetApplet extends JApplet implements ActionListener  {
  13.     SnmpTarget target;
  14.     PropertySettings pptysettings = new PropertySettings(this);
  15.     JButton button = new JButton();
  16.     JButton button1 = new JButton();
  17.     JButton button2 = new JButton();
  18.     JTextField textfield = new JTextField();
  19.     JTextField textfield1 = new JTextField();
  20.     JLabel label = new JLabel();
  21.   
  22.     public SnmpGetApplet()
  23.     {
  24. super();
  25.     }
  26.     public void init() {
  27.     getContentPane().setLayout(null);
  28.     getContentPane().add(label);
  29.     label.setBounds(105,40,105,25);
  30.     label.setText("Enter the OID");
  31.     getContentPane().add(textfield1);
  32.     textfield1.setBounds(210,40,140,25);
  33.     getContentPane().add(textfield);
  34.     textfield.setBounds(30,80,490,85);
  35.     getContentPane().add(button);
  36.     button.setBounds(80,195,105,35);
  37.     button.setText("GET");
  38.     
  39.     getContentPane().add(button1);
  40.     button1.setBounds(185,195,105,35);
  41.     button1.setText("GET NEXT");
  42.     getContentPane().add(button2);
  43.     button2.setBounds(290,195,105,35);
  44.     button2.setText("Clear");
  45.     
  46.     getContentPane().add(pptysettings);
  47.     pptysettings.setBounds(395,190,85,55);
  48.     }
  49.     public void start() {
  50.     target = new SnmpTarget(this);
  51.     target.setTargetHost("localhost");  
  52.     pptysettings.addVetoableChangeListener(target);
  53.     button.addActionListener(this); 
  54.     button1.addActionListener(this); 
  55.     button2.addActionListener(this); 
  56.     }
  57.    
  58.     public void actionPerformed(ActionEvent e) {
  59. if (e.getActionCommand().equals("GET")) {
  60.     
  61.     target.setObjectID(textfield1.getText()); 
  62.     textfield.setText(target.snmpGet());
  63. }
  64. else if (e.getActionCommand().equals("GET NEXT")) {
  65.      textfield.setText(target.snmpGetNext());
  66. }
  67. else if (e.getActionCommand().equals("Clear")) {
  68.      textfield.setText("");
  69. }
  70.     }
  71.     
  72.  
  73. }
  74.