tableSettingsDemoAppn.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:4k
源码类别:
SNMP编程
开发平台:
C/C++
- /*$Id: tableSettingsDemoAppn.src,v 1.4 2002/09/09 05:35:19 tonyjpaul Exp $*/
- /*
- * @(#)tableSettingsDemoAppn.java
- * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
- * Please read the COPYRIGHTS file for more details.
- */
- /**
- * An example of using the SnmpTablePanel bean which is designed for large
- * table support.
- *
- * [-m] <mibs> - The mibs to be loaded.
- * [-c] <community> - community String. By default "public".
- * oid Mandatory - Give the Object Identifier .
- **/
- import javax.swing.*;
- import javax.swing.table.*;
- import java.awt.*;
- import java.beans.*;
- import java.awt.event.*;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import java.applet.Applet;
- import com.adventnet.snmp.beans.*;
- import com.adventnet.snmp.ui.*;
- import javax.swing.event.*;
- import java.io.*;
- public class tableSettingsDemoAppn extends JFrame implements ActionListener
- {
- static String values[] = { null};
- JLabel l1;
- JLabel l2;
- JButton b1;
- JTextField t1;
- JTextField t2;
- PropertySettings pass;
- static String oid;
- TableBean tablePanel;
- /** Supply command line arguments to this constructor **/
- public tableSettingsDemoAppn(String mibs, String tableOID, String host)
- {
- try {
- UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- System.err.println("Couldn't use the system look and feel: "+ e);
- }
- getContentPane().setLayout(null);
- setBackground(Color.lightGray);
- pass = new PropertySettings();
- l1 = new JLabel( "Table OID" );
- l2 = new JLabel("Result");
- b1 = new JButton();
- b1.setLabel("Get Agent Data");
- t1 = new JTextField("The Table OID is shown here");
- t2 = new JTextField("The data from the agent is shown here");
- b1.addActionListener(this);
- pass.setBounds(70,10,100,45);
- getContentPane().add(pass);
- l1.reshape(30,75,100,25);
- getContentPane().add(l1);
- t1.reshape(150,75,250,25);
- getContentPane().add(t1);
- l2.reshape(30,120,100,25);
- getContentPane().add(l2);
- tablePanel = new TableBean();
- tablePanel.setBackground(Color.white);
- tablePanel.setVisible(true);
- tablePanel.reshape(30,160,500,250);
- getContentPane().add(tablePanel);
- b1.setBounds(70, 430, 100, 25);
- getContentPane().add(b1);
- tablePanel.setTargetHost(host);
- settings(mibs);
- setTableOID(tableOID);
- }
- public void settings(String mibs)
- {
- try {
- pass.addVetoableChangeListener(tablePanel);
- tablePanel.setMibModules( mibs );
- if(values[0] != null)
- tablePanel.setCommunity( values[0]);
- } catch (Exception ex) {
- System.err.println("Error in starting application: "+ex+":"+ex.getMessage());
- }
- }
- void setTableOID(String oid) {
- tablePanel.setTableOID(oid);
- }
- public void actionPerformed(ActionEvent e)
- {
- tablePanel.setTableOID( t1.getText());
- RequestEvent evt = new RequestEvent(b1,
- tablePanel.getTableOID(), RequestEvent.GET);
- }
- public static void main(String[] args)
- {
- String usage = "java tableSettingsDemoAppn MIB_files [-c community] oid host";
- String options[] = {"-c"};
- ParseOptions opt = new ParseOptions(args,options,values, usage);
- if (opt.remArgs.length < 3) opt.usage_error();
- try {
- UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- System.err.println("Couldn't use the system look and feel: "+ e);
- }
- tableSettingsDemoAppn app = new tableSettingsDemoAppn(opt.remArgs[0], opt.remArgs[1], opt.remArgs[2]);
- app.t1.setText(opt.remArgs[1]);
- WindowListener l = new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- };
- app.addWindowListener(l);
- app.setSize(700,500);
- app.setVisible(true);
- }
- }