File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments