import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class ip extends JFrame
implements ActionListener
{
private static final long serialVersionUID = 3339481369781127417L;
JButton jb1;
JButton jb2;
JButton jb3;
JPanel jp;
JLabel jl;
JLabel jl1;
JTextField jt;
public ip()
{
this.jp = new JPanel();
this.jl = new JLabel();
this.jl1 = new JLabel("您的域名:");
this.jb1 = new JButton("提交");
this.jb2 = new JButton("重置");
this.jb3 = new JButton("退出");
this.jt = new JTextField(20);
this.jb1.addActionListener(this);
this.jb2.addActionListener(this);
this.jb3.addActionListener(this);
this.jp.setLayout(new GridLayout(3, 2));
this.jp.add(this.jl1);
this.jp.add(this.jt);
this.jp.add(this.jb1);
this.jp.add(this.jl);
this.jp.add(this.jb2);
this.jp.add(this.jb3);
setBounds(200, 200, 500, 240);
add(this.jp);
setVisible(true);
setDefaultCloseOperation(3);
}
public static void main(String[] args)
{
new ip();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.jb1) {
String url = this.jt.getText();
InetAddress ip = null;
try {
ip = InetAddress.getByName(url);
}
catch (UnknownHostException e1) {
e1.printStackTrace();
}
this.jl.setText(ip.toString());
}
else if (e.getSource() == this.jb2) {
this.jl.setText("");
this.jt.setText("");
} else {
System.exit(0);
}
}
}
分享到:
相关推荐
java 获取IP地址 ...............................................................................
java程序实现获取IP地址、 java获取IP地址的方法
java获取ip地址返回国家、地区,城市名称,包含QQwry ip库
程序很小 但是很精悍,利用了GUI,但是界面还是很差
通过输入的ip地址,读取纯真ip数据库,获取该IP地址所在地区
java获取IP地址的工具类,使用时传入HttpServletRequest request类型的参数即可。使用例子 public static void logPageError(HttpServletRequest request){IpUtils.getIpAddr(request))}
用java获取IP地址方法讲述,文中讲述了用java获取IP地址的所有方法,希望对读者有些帮助!
使用intellij idea java开发软件,通过servlet获取访问用户的真实ip地址
java 获取计算机名与IP地址 java 获取计算机名与IP地址 java 获取计算机名与IP地址
在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的。但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实IP地址了
NULL 博文链接:https://fanshuyao.iteye.com/blog/2436489
java根据ip获取国家、地区名称,附带ip地址库
根据Ip地址获取归属地,需要用到ip库,我这里用到的是QQWry.dat
利用淘宝IP地址库实现的利用IP获取用户所在地工具类
主要介绍了java实现根据ip地址获取地理位置的代码分享,本文中使用的是QQ在线接口,也可以使用新浪、淘宝等提供的在线接口,需要的朋友可以参考下
获取客户端ip地址( 这个必须从客户端传到后台): jsp页面下,很简单,request.getRemoteAddr() ; 因为系统的VIew层是用JSF来实现的,因此页面上没法直接获得类似request,在bean里做了个强制转换java 获取客户端ip ...
Java获取客户端真实IP地址
通过该工具类可以获得请求的IP地址,适用于后台管理系统的信息统计。