java 网络抓包程序_基于java的网络抓包方法(转)

de was edited or generated using CloudGarden's Jigloo

* SWT/Swing GUI Builder, which is free for non-commercial

* use. If Jigloo is being used commercially (ie, by a corporation,

* company or business for any purpose whatever) then you

* should purchase a license for each developer using Jigloo.

* Please visit www.cloudgarden.com for details.

* Use of Jigloo implies acceptance of these licensing terms.

* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR

* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED

* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.

*/

public class Jcapturedialog extends javax.swing.JDialog implements ActionListener {

/**

* Auto-generated main method to display this JDialog

*/

static JpcapCaptor jpcap=null;

private JRadioButton wholeRadioButton;

private JPanel buttonPanel;

private JButton cancelButton;

private JButton okButton;

private JRadioButton userRadioButton;

private JRadioButton headRadioButton;

private JPanel netPanel;

private JTextField caplenTextField;

private JPanel caplenPanel;

private JTextField TextField;

private JPanel filterPanel;

private JCheckBox CheckBox;

private JComboBox netJComboBox;

private JPanel jPanel_east;

private JPanel jPanel_west;

NetworkInterface[] devices;

public static void main(String[] args) {

JFrame frame = new JFrame();

Jcapturedialog inst = new Jcapturedialog(frame);

inst.setVisible(true);

}

public Jcapturedialog(JFrame frame) {

super(frame,"选择要检测的网卡并设置参数",true);

try {

BoxLayout thisLayout = new BoxLayout(

getContentPane(),

javax.swing.BoxLayout.X_AXIS);

getContentPane().setLayout(thisLayout);

{

jPanel_west = new JPanel();

jPanel_west.setLayout(new BoxLayout(jPanel_west,BoxLayout.Y_AXIS));

getContentPane().add(jPanel_west);

{

netPanel = new JPanel();

FlowLayout netPanelLayout = new FlowLayout();

netPanelLayout.setAlignOnBaseline(true);

netPanel.setBorder(BorderFactory.createTitledBorder("选择网卡"));

netPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

jPanel_west.add(netPanel);

netPanel.setLayout(netPanelLayout);

//                                 netPanel.setPreferredSize(new java.awt.Dimension(239, 56));

{

devices = JpcapCaptor.getDeviceList();

if(devices == null){

JOptionPane.showMessageDialog(frame, "没有找到网卡");

dispose();

return;

}

else{

String[] names = new String[devices.length];

for(int i=0;i < names.length;i++){

names[i] = (devices[i].description == null?devices[i].name:devices[i].description);

}

netJComboBox = new JComboBox(names);

}

netPanel.add(netJComboBox);

}

}

{

CheckBox = new JCheckBox();

jPanel_west.add(CheckBox);

FlowLayout CheckBoxLayout = new FlowLayout();

CheckBoxLayout.setAlignOnBaseline(true);

CheckBox.setText("\是\否\设\置\为\混\杂\模\式");

CheckBox.setLayout(null);

}

{

filterPanel = new JPanel();

filterPanel.setBorder(BorderFactory.createTitledBorder("捕获过滤器"));

filterPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

FlowLayout filterPanelLayout = new FlowLayout();

filterPanelLayout.setAlignment(FlowLayout.LEFT);

filterPanelLayout.setAlignOnBaseline(true);

jPanel_west.add(filterPanel);

filterPanel.setLayout(filterPanelLayout);

{

TextField = new JTextField(20

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值