【发布时间】:2011-10-17 03:35:58
【问题描述】:
我试图制作一个带有按钮和文本区域/标签的 jFrame,其动机是能够检索我的系统 IP 地址,但问题是,当我使用此代码时
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
InetAddress ownIP=InetAddress.getLocalHost();
jTextField1.setText(ownIP.getHostAddress());
}
catch (Exception e)
{
jTextField1.setText(e.getMessage());
}
}
但这给了我回环 IP 地址 127.0.0.1 :( 我在我的系统上配置了静态 IP,但是该 IP 也没有显示 我使用 NetBeans IDE 7.0 和 Ubuntu 11.04
【问题讨论】:
-
看看这个,它可能会有所帮助:stackoverflow.com/questions/494465/…
-
它们都不起作用,想知道为什么... :(