⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managersnmp.java

📁 很不错java的SNMP应用例子
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    	jp_snmpv1_Con.add(jtf_snmpv1_IP,null);
    	
    	jl_snmpv1_pto = new JLabel("Puerto de Comunicaciones");//USO DEL JLABEL
    	jl_snmpv1_pto.setBounds(new Rectangle(76,126,160,20));//establece el xy del componente
    	jp_snmpv1_Con.add(jl_snmpv1_pto,null);
    
    	jtf_snmpv1_pto = new JTextField();//USO DEL JTEXTFIELD
    	jtf_snmpv1_pto.setBounds(new Rectangle(246,126,160,20));//establece el xy del componente
    	jtf_snmpv1_pto.setText(String.valueOf(pto));
    	jp_snmpv1_Con.add(jtf_snmpv1_pto,null);
    	
    	jl_snmpv1_comLec = new JLabel("Comunidad de Lectura");//USO DEL JLABEL
    	jl_snmpv1_comLec.setBounds(new Rectangle(76,206,160,20));//establece el xy del componente
    	jp_snmpv1_Con.add(jl_snmpv1_comLec,null);
    	
     	jtf_snmpv1_comLec = new JPasswordField();//USO DEL JPASSWORDFIELD
    	jtf_snmpv1_comLec.setBounds(new Rectangle(246,206,160,20));//establece el xy del componente
    	jtf_snmpv1_comLec.setEchoChar('*');
    	jtf_snmpv1_comLec.setText(String.valueOf(comLec));
    	//jpf_snmpv1_comEsc.setEchoChar((char)0);
    	jp_snmpv1_Con.add(jtf_snmpv1_comLec,null);
    	
    	jtf_snmpv1_comEsc = new JLabel("Comunidad de Escritura");//USO DEL JLABEL
    	jtf_snmpv1_comEsc.setBounds(new Rectangle(76,246,160,20));//establece el xy del componente
    	jp_snmpv1_Con.add(jtf_snmpv1_comEsc,null);
    
    	jpf_snmpv1_comEsc = new JPasswordField();//USO DEL JPASSWORDFIELD
    	jpf_snmpv1_comEsc.setBounds(new Rectangle(246,246,160,20));//establece el xy del componente
    	jpf_snmpv1_comEsc.setEchoChar('*');
    	jpf_snmpv1_comEsc.setText(String.valueOf(comEsc));
    	//jpf_snmpv1_comEsc.setEchoChar((char)0);
    	jp_snmpv1_Con.add(jpf_snmpv1_comEsc,null);

    	jl_snmpv1_VerCom = new JLabel("Visualizar Comunidades");//USO DEL JLABEL
    	jl_snmpv1_VerCom.setBounds(new Rectangle(76,166,160,20));//establece el xy del componente
    	jp_snmpv1_Con.add(jl_snmpv1_VerCom,null);

	    jcb_snmpv1_VerCom = new JComboBox();//USO DEL JCOMBOBOX
	  	jcb_snmpv1_VerCom.setBounds(new Rectangle(246,166,160,20));  
		jcb_snmpv1_VerCom.addItem("Si");
	  	jcb_snmpv1_VerCom.addItem("No");
	  	jcb_snmpv1_VerCom.setSelectedIndex(1);	  	 
	  	jp_snmpv1_Con.add(jcb_snmpv1_VerCom,null);

	  	jcb_snmpv1_VerCom.addActionListener(new ActionListener(){
	      public void actionPerformed(ActionEvent e) {	          
	        if ((jcb_snmpv1_VerCom.getSelectedItem())==opcionSi){jpf_snmpv1_comEsc.setEchoChar((char)0);jtf_snmpv1_comLec.setEchoChar((char)0);}; 
	        if ((jcb_snmpv1_VerCom.getSelectedItem())==opcionNo){jpf_snmpv1_comEsc.setEchoChar('*');jtf_snmpv1_comLec.setEchoChar('*');}; 	
	      }
	    });
	    
    	jl_snmpv1_inten = new JLabel("Nro. de Intentos");//USO DEL JLABEL
    	jl_snmpv1_inten.setBounds(new Rectangle(76,286,160,20));//establece el xy del componente
    	jp_snmpv1_Con.add(jl_snmpv1_inten,null);
    
    	jtf_snmv1_inten = new JTextField();//USO DEL JTEXTFIELD
    	jtf_snmv1_inten.setBounds(new Rectangle(246,286,160,20));//establece el xy del componente
    	jtf_snmv1_inten.setText(String.valueOf(inten));
    	jp_snmpv1_Con.add(jtf_snmv1_inten,null);
    	
    	jl_snmpv1_timeOut = new JLabel("Tiempo de Espera (ms)");//USO DEL JLABEL
    	jl_snmpv1_timeOut.setBounds(new Rectangle(76,326,160,20));//establece el xy del componente
    	jp_snmpv1_Con.add(jl_snmpv1_timeOut,null);
    
    	jtt_snmpv1_timeOut = new JTextField();//USO DEL JTEXTFIELD
    	jtt_snmpv1_timeOut.setBounds(new Rectangle(246,326,160,20));//establece el xy del componente
    	jtt_snmpv1_timeOut.setText(String.valueOf(timeOut));
    	jp_snmpv1_Con.add(jtt_snmpv1_timeOut,null);
    	
    	jb_snmpv1_aplicarPara = new JButton("Aplicar Cambios");
	    jb_snmpv1_aplicarPara.setBounds(new Rectangle(141,376,200,20));
	    jb_snmpv1_aplicarPara.setToolTipText("Presione para establecer los nuevos par醡etros.");
	    jp_snmpv1_Con.add(jb_snmpv1_aplicarPara,null);
	
		jb_snmpv1_aplicarPara.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent e) {
          	String men_err = "";
          	boolean men_err_l = false;

          		if (esVacio(jtf_snmpv1_IP.getText())){          			
          		  men_err = men_err.concat(configParamError01);	 	
          	  	  men_err_l =true;
          	  	}
          	  	
          	  	if (!(ipValida(jtf_snmpv1_IP.getText()))){
          	  	  men_err = men_err.concat(configParamError02);	 	
          	  	  men_err_l =true;
          	  	}
          	  	
          	  	
          		if (!(esNumero(jtf_snmpv1_pto.getText()))){          			
          		  men_err = men_err.concat(configParamError03);	 	
          	  	  men_err_l =true;
          	  	}

          	  	if (esVacio(jpf_snmpv1_comEsc.getText())){          			
          		  men_err = men_err.concat(configParamError04);	 	
          	  	  men_err_l =true;
          	  	}

          	  	if (esVacio(jtf_snmpv1_comLec.getText())){          			
          		  men_err = men_err.concat(configParamError05);	 	
          	  	  men_err_l =true;
          	  	}
          	  	
          		if (!(esNumero(jtf_snmv1_inten.getText()))){          			
          		  men_err = men_err.concat(configParamError06);	 	
          	  	  men_err_l =true;
          	  	}

          		if ((esNumero(jtf_snmv1_inten.getText()))&&(Integer.parseInt(jtf_snmv1_inten.getText())<=0)){          			
          		  men_err = men_err.concat(configParamError07);	 	
          	  	  men_err_l =true;
          	  	}

          		if (!(esNumero(jtt_snmpv1_timeOut.getText()))){          			
          		  men_err = men_err.concat(configParamError08);	 	
          	  	  men_err_l =true;
          	  	}

          		if ((esNumero(jtt_snmpv1_timeOut.getText()))&&(Integer.parseInt(jtt_snmpv1_timeOut.getText())<=0)){          			
          		  men_err = men_err.concat(configParamError09);	 	
          	  	  men_err_l =true;
          	  	}


          		if (men_err_l){          			
				JOptionPane.showMessageDialog(managerSNMP.this,men_err,nombreDelPrograma,JOptionPane.ERROR_MESSAGE,(new ImageIcon("imagenes/no.gif")));  	          	  	          	  
		    	if (esVacio(jtf_snmpv1_IP.getText())){jtf_snmpv1_IP.setText(String.valueOf(IP));}
		    	if (!(ipValida(jtf_snmpv1_IP.getText()))){jtf_snmpv1_IP.setText(String.valueOf(IP));}
		    	if (!(esNumero(jtt_snmpv1_timeOut.getText()))){jtt_snmpv1_timeOut.setText(String.valueOf(timeOut));}
		    	if ((esNumero(jtt_snmpv1_timeOut.getText()))&&(Integer.parseInt(jtt_snmpv1_timeOut.getText())<=0)){jtt_snmpv1_timeOut.setText(String.valueOf(timeOut));}
		    	if (!(esNumero(jtf_snmv1_inten.getText()))){jtf_snmv1_inten.setText(String.valueOf(inten));}
		    	 if ((esNumero(jtf_snmv1_inten.getText()))&&(Integer.parseInt(jtf_snmv1_inten.getText())<=0)){jtf_snmv1_inten.setText(String.valueOf(inten));}
				if (!(esNumero(jtf_snmpv1_pto.getText()))){jtf_snmpv1_pto.setText(String.valueOf(pto));}    
				if (esVacio(jpf_snmpv1_comEsc.getText())){jpf_snmpv1_comEsc.setText(String.valueOf(comEsc));}
				if (esVacio(jtf_snmpv1_comLec.getText())){jtf_snmpv1_comLec.setText(String.valueOf(comLec));}

				} else {          	  	          	  	
          		IP =		 jtf_snmpv1_IP.getText();
          		pto =	 Long.parseLong(jtf_snmpv1_pto.getText());
          		comLec =	 jtf_snmpv1_comLec.getText();
          		comEsc =	 jpf_snmpv1_comEsc.getText();
          		inten =	 Integer.parseInt(jtf_snmv1_inten.getText());
          		timeOut = Integer.parseInt(jtt_snmpv1_timeOut.getText());
				
				JOptionPane.showMessageDialog(managerSNMP.this, configParamResult01 ,nombreDelPrograma,JOptionPane.INFORMATION_MESSAGE,(new ImageIcon("imagenes/help.gif")));

				//PARA LLENAR LOS PARAMETROS DE SNMPv2c					
				jtf_snmpv2c_IP.setText(IP);
          		jtf_snmpv2c_pto.setText(String.valueOf(pto));
          		jtf_snmpv2c_comLec.setText(comLec);
          		jpf_snmpv2c_comEsc.setText(comEsc);
          		jtf_snmv2c_inten.setText(String.valueOf(inten));
          		jtt_snmpv2c_timeOut.setText(String.valueOf(timeOut));
          		
          		//PARA LLENAR LOS PARAMETROS DE SNMPv3	
				jtf_snmpv3_IP.setText(IP);
          		jtf_snmpv3_pto.setText(String.valueOf(pto));
          		jtf_snmv3_inten.setText(String.valueOf(inten));
          		jtt_snmpv3_timeOut.setText(String.valueOf(timeOut));	
				}
         	}
       	});
	    //----------------------------------Fin de Pantalla de Conexi髇----------------------------
	    
	    
	    //----------------------------------Pantalla de Get----------------------------------------  	
	    jp_snmpv1_Get = new JPanel();
	    //jp_snmpv1_Get.setBackground(Color.blue);
		//jp_snmpv1_Get.setBorder(BorderFactory.createTitledBorder("Comando Get de SNMPv1"));
		jp_snmpv1_Get.setBounds(new Rectangle(0,30,483,483));
		jp_snmpv1_Get.setBorder(BorderFactory.createTitledBorder("Comando Get"));
		jp_snmpv1_Get.setLayout(null);
		jp_snmpv1_Get.setVisible(false);
		snmpv1.add(jp_snmpv1_Get,null);    	    	
    	
    	jsp_snmpv1_getDescrip = new JScrollPane();
    	jsp_snmpv1_getDescrip.setBounds(new Rectangle(10,20,465,270));
    	jsp_snmpv1_getDescrip.setWheelScrollingEnabled(true);
    	jp_snmpv1_Get.add(jsp_snmpv1_getDescrip,null);
    	
    	jta_snmpv1_getDescrip = new JTextArea();
    	jta_snmpv1_getDescrip.setText("");
    	jta_snmpv1_getDescrip.setEditable(false);
    	jsp_snmpv1_getDescrip.getViewport().add(jta_snmpv1_getDescrip,null);
    	
    	jl_snmpv1_getEtiGet = new JLabel("OID");
	    jl_snmpv1_getEtiGet.setBounds(new Rectangle(10,300,20,20));
	    jp_snmpv1_Get.add(jl_snmpv1_getEtiGet,null);
	    
	    jtf_snmpv1_getGet = new JTextField();
	    jtf_snmpv1_getGet.setBounds(new Rectangle(40,300,245,20));   
	    jtf_snmpv1_getGet.setEditable(true);
	    jp_snmpv1_Get.add(jtf_snmpv1_getGet,null);

    	jb_snmpv1_add = new JButton("A馻dir");
	    jb_snmpv1_add.setBounds(new Rectangle(295,300,79,20));  //9999
	    jb_snmpv1_add.setToolTipText("Presione para agregar el OID.");
	    jp_snmpv1_Get.add(jb_snmpv1_add,null);
	    
    	jl_snmpv1_getObjs = new JLabel("Objetos");
	    jl_snmpv1_getObjs.setBounds(new Rectangle(10,330,60,20));
	    jp_snmpv1_Get.add(jl_snmpv1_getObjs,null);
	    
	    jtf_snmpv1_getObjs = new JTextField();
	    jtf_snmpv1_getObjs.setBounds(new Rectangle(60,330,344,20));   
	    jtf_snmpv1_getObjs.setEditable(false);	    	    
	    jp_snmpv1_Get.add(jtf_snmpv1_getObjs,null);

    	jb_snmpv1_undo = new JButton("Deshacer");
	    jb_snmpv1_undo.setBounds(new Rectangle(384,300,90,20));  //9999
	    jb_snmpv1_undo.setToolTipText("Presione para eliminar el 鷏timo OID de los objetos.");
	    jp_snmpv1_Get.add(jb_snmpv1_undo,null);

    	jb_snmpv1_getGet = new JButton("Get");
	    jb_snmpv1_getGet.setBounds(new Rectangle(415,330,59,20));  
	    jb_snmpv1_getGet.setToolTipText("Presione para obtener el valor.");
	    jp_snmpv1_Get.add(jb_snmpv1_getGet,null);
	    
	    jsp_snmpv1_getResp = new JScrollPane();
    	jsp_snmpv1_getResp.setBounds(new Rectangle(10,360,465,111));  
    	jsp_snmpv1_getResp.setWheelScrollingEnabled(true);
    	jp_snmpv1_Get.add(jsp_snmpv1_getResp,null);
    	
    	jta_snmpv1_getResp = new JTextArea();
    	jta_snmpv1_getResp.setText("");
    	jta_snmpv1_getResp.setEditable(false);
    	jsp_snmpv1_getResp.getViewport().add(jta_snmpv1_getResp,null);

		compuestoGetSNMPv1Temp = new Vector();
	    	    
	    //Para el boton a馻dir
	    jb_snmpv1_add.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent e) {
        	  
        	  //aqui lo que hace
          	  if ((jtf_snmpv1_getGet.getText()).equals("")){
          	    JOptionPane.showMessageDialog(managerSNMP.this,erroresGenerales01,nombreDelPrograma,JOptionPane.ERROR_MESSAGE,(new ImageIcon("imagenes/no.gif")));
          	  }else{
          	  	//Tratamiento
          	  	OID = jtf_snmpv1_getGet.getText();
          	  	
          	  	if (esVacio(IP)){
          	  	  JOptionPane.showMessageDialog(managerSNMP.this,configParamError01,nombreDelPrograma,JOptionPane.ERROR_MESSAGE,(new ImageIcon("imagenes/no.gif")));  	
          	  	}else{        	  	
          	  	          	  	
					//Para transformar el OID de string al arreglo para pasarsel

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -