Java Swing AWT Program to Find IP Address of Website URL Using Networking GUI Desktop App

You are currently viewing Java Swing AWT Program to Find IP Address of Website URL Using Networking GUI Desktop App

In this article, I wish to explain the concept of “Java Swing AWT Program to Find IP Address of Website URL Using Networking GUI Desktop App”. Let’s start the explanation to clear the topic below.

Java Swing AWT Program to Find IP Address of Website URL Using Networking GUI Desktop App

ipfinder.java

import javax.swing.*;  
import java.awt.event.*;  
import java.net.*;  
public class IPFinder extends JFrame implements ActionListener{  
    JLabel l;  
    JTextField tf;  
    JButton b;  
IPFinder(){  
    super("IP Finder Tool - Javatpoint");  
    l=new JLabel("Enter URL:");  
    l.setBounds(50,70,150,20);;  
    tf=new JTextField();  
    tf.setBounds(50,100,200,20);  
      
    b=new JButton("Find IP");  
    b.setBounds(50,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);  
    } catch (UnknownHostException e1) {  
        JOptionPane.showMessageDialog(this,e1.toString());  
    }  
}  
public static void main(String[] args) {  
    new IPFinder();  
}  
}

Final Thoughts

I hope this article helps you learn the “Java Swing AWT Program to Find IP Address of Website URL Using Networking GUI Desktop App”. If you face any issues please let me know via the comment section. Share this article with other Java program developers via social networks. Thank You!

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply