Skip to content

Commit a50c33b

Browse files
Merge pull request #298 from sh4d0wy/main
Create swingIpFInder.java
2 parents a861971 + 2c84e05 commit a50c33b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

swingIpFInder.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import javax.swing.*;
2+
import java.awt.event.*;
3+
import java.net.*;
4+
public class IPFinder extends JFrame implements ActionListener{
5+
JLabel l;
6+
JTextField tf;
7+
JButton b;
8+
IPFinder(){
9+
super("IP Finder Tool - Javatpoint");
10+
l=new JLabel("Enter URL:");
11+
l.setBounds(50,70,150,20);;
12+
tf=new JTextField();
13+
tf.setBounds(50,100,200,20);
14+
15+
b=new JButton("Find IP");
16+
b.setBounds(50,150,80,30);
17+
b.addActionListener(this);
18+
add(l);
19+
add(tf);
20+
add(b);
21+
setSize(300,300);
22+
setLayout(null);
23+
setVisible(true);
24+
}
25+
public void actionPerformed(ActionEvent e){
26+
String url=tf.getText();
27+
try {
28+
InetAddress ia=InetAddress.getByName(url);
29+
String ip=ia.getHostAddress();
30+
JOptionPane.showMessageDialog(this,ip);
31+
} catch (UnknownHostException e1) {
32+
JOptionPane.showMessageDialog(this,e1.toString());
33+
}
34+
}
35+
public static void main(String[] args) {
36+
new IPFinder();
37+
}
38+
}

0 commit comments

Comments
 (0)