[求助]本机ip问题
import javax.swing.JFrame;
import java.net.*;
import java.awt.*;
public class ip extends JFrame{
InetAddress inet;
ip(){
setTitle("本机IP测试");
setSize(300,250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try{
inet=InetAddress.getLocalHost();
}catch(UnKnownHostException e){};
setVisible(true);
}
public void paint(Graphics g){
g.drawString("本机IP地址为:"+inet.getHostAddress(),30,50);
}
public static void main(String[] agrs){
ip ip=new ip();
}
}