📄 configdialog.java
字号:
/*JAdhoc ver 0.11 - Java AODV (RFC 3561) Protocol HandlerCopyright 2003-2004 ComNets, University of BremenThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/package jadhoc.gui;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*;import jadhoc.conf.*;/*** Class to display the configuration user interface and update* the changes to the configuration.** @author : Asanga Udugama* @date : 28-jul-2003* @email : adu@comnets.uni-bremen.de**/public class ConfigDialog extends JDialog { ConfigInfo cfgInfo, tempCfgInfo; JPanel pnlCfgPanel, pnlBtnPanel; JButton btnUpdate, btnCancel; public static final int DIALOG_WIDTH = 500; public static final int DIALOG_HEIGHT = 280; /** * Constructs a configuration information display and shows it. * @param ConfigInfo cfg - the configuration object * @param GUI gui - main user interface */ public ConfigDialog(ConfigInfo cfg, GUI gui) { super(gui, "J-Adhoc Configuration", true); cfgInfo = cfg; tempCfgInfo = new ConfigInfo(); tempCfgInfo.setValuesUsing(cfgInfo); pnlCfgPanel = new JPanel(); pnlCfgPanel.setLayout(new BorderLayout()); pnlBtnPanel = new JPanel(); btnUpdate = new JButton("Update"); btnUpdate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { updateConfigInfo(); } }); btnCancel = new JButton("Cancel"); btnCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { cancelConfigUpdate(); } }); pnlBtnPanel.add(btnUpdate); pnlBtnPanel.add(btnCancel); pnlCfgPanel.add(new JScrollPane(new JTable(new CfgTblModel()))); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { cancelConfigUpdate(); } }); getContentPane().setLayout(new BorderLayout()); getContentPane().add("Center", pnlCfgPanel); getContentPane().add("South", pnlBtnPanel); getContentPane().setBackground(Color.gray); setResizable(false); int x = (int) (gui.getLocation().getX() + ((gui.getSize().getWidth() - DIALOG_WIDTH) / 2)); int y = (int) (gui.getLocation().getY() + ((gui.getSize().getHeight() - DIALOG_HEIGHT) / 2)); setLocation(x, y); setSize(DIALOG_WIDTH, DIALOG_HEIGHT); setVisible(true); } /** * Inner class that extends the default table model to handle * the JTable associated with displaying and updating configuration * information */ class CfgTblModel extends DefaultTableModel { /** * Method to return the row count of the config info * table * @return int - row count */ public int getRowCount() { return 32; } /** * Method to return the column count of the config info * table * @return int - column count */ public int getColumnCount() { return 2; } /** * Method to return the value related to given row and * column * @param int row - the row of the value * @param int column - the column of the value * @return Object - the data value (string) */ public Object getValueAt(int row, int column) { if(row == 0 && column == 0) return tempCfgInfo.executionModeStr; else if(row == 0 && column == 1) return tempCfgInfo.executionMode; else if(row == 1 && column == 0) return tempCfgInfo.osInUseStr; else if(row == 1 && column == 1) return tempCfgInfo.osInUse; else if(row == 2 && column == 0) return tempCfgInfo.ipVersionStr; else if(row == 2 && column == 1) return tempCfgInfo.ipVersion; else if(row == 3 && column == 0) return tempCfgInfo.ipAddressStr; else if(row == 3 && column == 1) return tempCfgInfo.ipAddress; else if(row == 4 && column == 0) return tempCfgInfo.ifaceNameStr; else if(row == 4 && column == 1) return tempCfgInfo.ifaceName; else if(row == 5 && column == 0) return tempCfgInfo.ipAddressGatewayStr; else if(row == 5 && column == 1) return tempCfgInfo.ipAddressGateway; else if(row == 6 && column == 0) return tempCfgInfo.loIfaceNameStr; else if(row == 6 && column == 1) return tempCfgInfo.loIfaceName; else if(row == 7 && column == 0) return tempCfgInfo.loggingStatusStr; else if(row == 7 && column == 1) return tempCfgInfo.loggingStatus; else if(row == 8 && column == 0) return tempCfgInfo.loggingLevelStr; else if(row == 8 && column == 1) return tempCfgInfo.loggingLevel; else if(row == 9 && column == 0) return tempCfgInfo.logFileStr; else if(row == 9 && column == 1) return tempCfgInfo.logFile; else if(row == 10 && column == 0) return tempCfgInfo.pathToSystemCmdsStr; else if(row == 10 && column == 1) return tempCfgInfo.pathToSystemCmds; else if(row == 11 && column == 0) return tempCfgInfo.onlyDestinationStr; else if(row == 11 && column == 1) return tempCfgInfo.onlyDestination; else if(row == 12 && column == 0) return tempCfgInfo.gratuitousRREPStr; else if(row == 12 && column == 1) return tempCfgInfo.gratuitousRREP; else if(row == 13 && column == 0) return tempCfgInfo.RREPAckRequiredStr; else if(row == 13 && column == 1) return tempCfgInfo.RREPAckRequired; else if(row == 14 && column == 0) return tempCfgInfo.ipAddressMulticastStr; else if(row == 14 && column == 1) return tempCfgInfo.ipAddressMulticast; else if(row == 15 && column == 0) return tempCfgInfo.RERRSendingModeStr; else if(row == 15 && column == 1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -