-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPFinder.java
More file actions
54 lines (50 loc) · 1.41 KB
/
IPFinder.java
File metadata and controls
54 lines (50 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication;
/**
*
* @author Administrator
*/
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.*;
import java.awt.event.*;
import java.net.*;
public class IPFinder extends JFrame implements ActionListener{
JLabel l,l1;
JTextField tf;
JButton b;
IPFinder(){
super("IP Finder Tool");
getContentPane().setBackground( Color.CYAN);
l=new JLabel("Enter Website URL:");
l.setBounds(50,70,150,20);;
tf=new JTextField();
tf.setBounds(50,100,200,20);
b=new JButton("Find IP");
b.setBounds(100,150,80,30);
b.addActionListener(this);
add(l);
add(tf);
add(b);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
String url=tf.getText();
try {
InetAddress ia=InetAddress.getByName(url);
String ip=ia.getHostAddress();
JOptionPane.showMessageDialog(this,"IP of "+url+" is: "+ip);
} catch (UnknownHostException e1) {
JOptionPane.showMessageDialog(this,e1.toString());
}
}
public static void main(String[] args) {
new IPFinder();
}
}