This is a code for finding IP address of a URL. I have problem with compilation. I have put the whole code for clear understanding of my problem. Hope the image would help you. I would also like to know why url is being highlighted in red. Is it the cause of exception?
import javax.swing.*;
import java.awt.event.*;
import java.net.*;
public class IP extends JFrame implements ActionListener
{
JLabel l;
JTextField tf;
JButton b;
IP(){
super("IP Finder Tool");
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();
InetAddress ia=InetAddress.getByName(url);
String ip=ia.getHostAddress();
JOptionPane.showMessageDialog(this,ip);
}
public static void main()
{
new IPFinder();
}
}