
October 17th, 2006, 06:53 PM
|
 |
\ ^_^ / - Moderator
|
|
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 473
Time spent in forums: 2 Days 1 h 19 m 14 sec
Reputation Power: 3
|
|
|
Need to convert this completely to applet
the ajusted applet code that i had tryed to ajust is this...
Code:
package ip;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
public class Addrs extends JApplet{
static String[] top=new String[20];
static double counter=0;
public static void init(String[] args) throws SocketException {
Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
while (ifaces.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface)ifaces.nextElement();
Enumeration addrs = ni.getInetAddresses();
while (addrs.hasMoreElements()) {
InetAddress ia = (InetAddress)addrs.nextElement();
top[top.length]=ni.getName()+": " + ia.getHostAddress();
counter++;
}
}
for (int x=0;x<counter;x++) {
JOptionPane.showMessageDialog(null,top[x]);
System.out.println(top[x]);
}
}
}
the original application code is
Code:
package ip;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
public class Addrs {
public static void main(String[] args) throws SocketException {
Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
while (ifaces.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface)ifaces.nextElement();
System.out.println(ni.getName() + ":");
Enumeration addrs = ni.getInetAddresses();
while (addrs.hasMoreElements()) {
InetAddress ia = (InetAddress)addrs.nextElement();
System.out.println(" " + ia.getHostAddress());
}
}
}
}
Thanks,
colton22
|