SnmpMibTree.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:4k
- /* $Id: SnmpMibTree.java,v 1.2 2002/06/18 07:18:56 kousalya Exp $ */
- /* SnmpMibTree.java
- * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
- * Please read the associated COPYRIGHTS file for more details.
- */
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import com.adventnet.snmp.beans.*;
- import com.adventnet.snmp.ui.*;
- public class SnmpMibTree implements ActionListener {
- JTextArea textfield ;
- MibTree mibtree ;
- JButton loadbutton;
- JButton unloadbutton;
- JButton describebutton;
- JButton clearbutton ;
- public SnmpMibTree()
- {
- textfield = new JTextArea();
- mibtree = new MibTree();
- loadbutton = new JButton();
- unloadbutton = new JButton();
- describebutton = new JButton();
- clearbutton = new JButton();
- }
- public static void main(String args[]) {
- SnmpMibTree builder = new SnmpMibTree();
- JFrame frame = new JFrame();
- frame.setVisible(true);
- frame.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent evt)
- {
- System.exit(0);
- }
- });
- frame.setSize(650,575);
- frame.setTitle(" AdventNet SNMP Tutorial - Loading and unloading MIB's");
- frame.getContentPane().setLayout(null);
- frame.getContentPane().add(builder.textfield);
- builder.textfield.setBounds(220,160,390,235);
- frame.getContentPane().add(builder.loadbutton);
- builder.loadbutton.setBounds(10,10,105,35);
- builder.loadbutton.setText("Load MIB");
- frame.getContentPane().add(builder.unloadbutton);
- builder.unloadbutton.setBounds(115,10,105,35);
- builder.unloadbutton.setText("Unload MIB");
- frame.getContentPane().add(builder.describebutton);
- builder.describebutton.setBounds(220,10,105,35);
- builder.describebutton.setText("Description");
- frame.getContentPane().add(builder.clearbutton);
- builder.clearbutton.setBounds(325,10,105,35);
- builder.clearbutton.setText("Clear");
- frame.getContentPane().add(builder.mibtree);
- builder.mibtree.setBounds(5,80,205,405);
- try {
- builder.mibtree.addMib("RFC1213-MIB");
- }
- catch (Exception ex) {
- }
- builder.loadbutton.addActionListener(builder);
- builder.unloadbutton.addActionListener(builder);
- builder.describebutton.addActionListener(builder);
- builder.clearbutton.addActionListener(builder);
- frame.show();
- }
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equals("Load MIB")) {
- JFileChooser filechooser = new JFileChooser();
- filechooser.showDialog(mibtree, "open");
- try {
- mibtree.addMib(filechooser.getSelectedFile().toString());
- }
- catch (Exception ex) {
- }
- }
- else if (e.getActionCommand().equals("Unload MIB")) {
- try {
- mibtree.deleteMib(mibtree.getSelectedMibModule().getName().toString());
- }
- catch (Exception ex) {
- }
- }
- else if (e.getActionCommand().equals("Description")) {
- textfield.setText("Syntax:"+mibtree.getSelectedMibNode().getSyntax()+"n"+"Access:"+mibtree.getSelectedMibNode().printAccess()+"n"+"Status:"+mibtree.getSelectedMibNode().getStatus()+"n"+"Reference:"+mibtree.getSelectedMibNode().getReference()+"n"+"OID:"+mibtree.getSelectedMibNode().getNumberedOIDString()+"n"+"Node:"+mibtree.getSelectedMibNode().getOIDString()+"n"+"Description:"+mibtree.getSelectedMibNode().getDescription()+"n");
- }
- else if (e.getActionCommand().equals("Clear")) {
- textfield.setText("");
- }
- }
- }