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

📄 propertydialog.java

📁 snmp zip 包开发snmp协议
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// NAME//      $RCSfile: propertyDialog.java,v $// DESCRIPTION//      [given below in javadoc format]// DELTA//      $Revision: 1.5 $// CREATED//      $Date: 2006/01/26 12:47:16 $// COPYRIGHT//      Westhawk Ltd// TO DO///* * Copyright (C) 1998 - 2006 by Westhawk Ltd * * Permission to use, copy, modify, and distribute this software * for any purpose and without fee is hereby granted, provided * that the above copyright notices appear in all copies and that * both the copyright notice and this permission notice appear in * supporting documentation. * This software is provided "as is" without express or implied * warranty. * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a> */ package uk.co.westhawk.examplev1;import java.awt.*; import javax.swing.*;import java.util.*;import java.awt.event.*;import java.beans.*;import uk.co.westhawk.snmp.beans.*;import uk.co.westhawk.snmp.stack.*;/** * <p> * The class propertyDialog is used to set the bean * properties. A user can add an actionListener to be notified when the * "Apply" or "OK" button is pressed. * </p> * * <p> * The user can configure the host name, the port number, the community * name, the socket type and the update interval.  * </p> * * <p> * The "Try it" button activates the IsHostReachableBean, who will probe * the configured host and signals the UI since when the host was up. * </p> * * @see uk.co.westhawk.snmp.beans.IsHostReachableBean * * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a> * @version $Revision: 1.5 $ $Date: 2006/01/26 12:47:16 $ */public class propertyDialog extends JDialog       implements ActionListener, PropertyChangeListener, WindowListener{    private static final String     version_id =        "@(#)$Id: propertyDialog.java,v 1.5 2006/01/26 12:47:16 birgit Exp $ Copyright Westhawk Ltd";    protected GridBagLayout gridBagLayout1;    protected JLabel hostLabel;    protected JLabel portLabel;    protected JLabel commLabel;    protected JLabel intLabel;    protected JLabel bindLabel;      protected JTextField hostText;    protected JTextField bindText;    protected JTextField portText;    protected JTextField communityText;    protected JTextField intervalText;       protected JLabel messageLabel;    protected IsHostReachableBean reachableBean;        protected JButton tryButton;    protected JButton okButton;    protected JButton cancelButton;    protected JButton applyButton;    protected String host;    protected String bindAddr;    protected String port;    protected String community;    protected String interval;    protected String socketType;    private JPanel socketPanel = new JPanel();    private ButtonGroup socketGroup = new ButtonGroup();    private JCheckBox standardSocketChoice = new JCheckBox();    private JCheckBox tcpSocketChoice = new JCheckBox();    private JCheckBox netscapeSocketChoice = new JCheckBox();    protected Vector actionPerformedListener = null;/** * The constructor to create a non-modal JDialog with the title "Property * JDialog". * * @param frame the parent frame */public propertyDialog(JFrame frame){    super (frame, "Property JDialog", false);    actionPerformedListener = new Vector();    jbInit();    socketGroup.add(standardSocketChoice);    socketGroup.add(tcpSocketChoice);    socketGroup.add(netscapeSocketChoice);    standardSocketChoice.setSelected(true);    if (frame != null)    {        Rectangle r = frame.getBounds();        this.setLocation(r.x, r.y+r.height);    }}/** * Sets the host string. * * @param s the string */public void setHost(String s){     host = s;     hostText.setText(host);}/** * Sets the local bind address * * @param s the string * @since 4_14 */public void setBindAddress(String s){     bindAddr = s;     bindText.setText(bindAddr);}/** * Sets the port string. * * @param s the string */public void setPort(String s){     port = s;     portText.setText(port);}/** * Sets the community name string. * * @param s the string */public void setCommunityName(String s){     community = s;     communityText.setText(community);}/** * Sets the update interval string. * * @param s the string */public void setUpdateInterval(String s){     interval = s;     intervalText.setText(interval);}/** * Sets the socket type string. * * @param s the socket type */public void setSocketType(String newVar){    socketType = newVar;    if (socketType.equals(SnmpContextBasisFace.NETSCAPE_SOCKET))    {        netscapeSocketChoice.setSelected(true);    }    else if (socketType.equals(SnmpContextBasisFace.TCP_SOCKET))    {        tcpSocketChoice.setSelected(true);    }    else    {        standardSocketChoice.setSelected(true);    }}/** * Returns the socket type string * * @return the socket type */public String getSocketType(){    return socketType;}/** * Returns the host string * * @return the string */public String getHost(){    return host;}/** * Returns the local bind address * * @return the string * @since 4_14 */public String getBindAddress(){    return bindAddr;}/** * Returns the port string * * @return the string */public String getPort(){    return port;}/** * * Returns the community name string * * @return the string */public String getCommunityName(){    return community;}/** * * Returns the update interval string * * @return the string */public String getUpdateInterval(){    return interval;}void tryButton_actionPerformed(ActionEvent e){    messageLabel.setText(" ");    reachableBean.setHost(hostText.getText());    reachableBean.setBindAddress(bindText.getText());    reachableBean.setPort(portText.getText());    reachableBean.setCommunityName(communityText.getText());    try    {        reachableBean.action();    }    catch (java.io.IOException exc)    {        messageLabel.setText("IOException " + exc.getMessage());    }    catch (uk.co.westhawk.snmp.stack.PduException exc)    {        messageLabel.setText("PduException " + exc.getMessage());    }}void reachableBean_propertyChange(PropertyChangeEvent e){    messageLabel.setText(reachableBean.getMessage());}void cancelButton_actionPerformed(ActionEvent e){    this.setVisible(false);    fireActionPerformed(e.getID(), e.getActionCommand(),          e.getModifiers());}void okButton_actionPerformed(ActionEvent e){    this.setVisible(false);    host = hostText.getText();    bindAddr = bindText.getText();    if (bindAddr.length() == 0)    {        bindAddr = null;    }    port = portText.getText();    community = communityText.getText();

⌨️ 快捷键说明

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