First Question
NetworkInterface.getNetworkInterfaces();
returns a Enumeration type. each element of the Enumeration has a getDisplayName() method which returns a string such as en0, en1, vnic1 etc. Now I would like to make these strings into a JComboBox. I'm Stuck trying to add these through
jComboBox1.setModel("Some code here");
One more question out of curiosity.. Why did the folks wo开发者_如何学Pythonrking on Java decide to use Enumeration instead of NetworkInterface?
Doesn't simply adding string to JComboBox works.
jComboBox.add(NetworkInterface.getNetworkInterfaces().en1.getDisplayName())
or if you want to handle it in model then write a class that implements ListCellRenderer and in its method getListCellRendererComponent() call your method of getting name and return that.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论