Skip to content

Instantly share code, notes, and snippets.

@blackraccoon000
Created January 28, 2011 03:44
Show Gist options
  • Save blackraccoon000/799798 to your computer and use it in GitHub Desktop.
Save blackraccoon000/799798 to your computer and use it in GitHub Desktop.
ComboBox7
package combotest;
import jpcap.JpcapCaptor;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemListener;
/**
* Created by IntelliJ IDEA.
* User: white
* Date: 11/01/28
* Time: 7:15
* To change this template use File | Settings | File Templates.
*/
public class ComboBox7 extends JFrame {
public static void main(String args []){
ComboBox7 frame = new ComboBox7();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(10,10,300,200);
frame.setTitle("Title");
frame.setVisible(true);
}
ComboBox7(){
jpcap.NetworkInterface device[] = JpcapCaptor.getDeviceList();{
String names[] = new String[device.length];
for(int i = 0; i<names.length ;i++){
names[i] = (device[i].description);
DefaultComboBoxModel model = new DefaultComboBoxModel(names);
JComboBox combo = new JComboBox(model);
combo.setPreferredSize(new Dimension(150,30));
JPanel p = new JPanel();
p.add(new JLabel("device"));
p.add(combo);
getContentPane().add(p,BorderLayout.CENTER);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment