Pessoal estou tentando problemas na compilação do seguinte código:
Erro de compilção:
Netinfo.java:59: unreported exception java.net.MalformedURLException; must be caught or declared to be thrown
url = new URL(texto1.getText());
^
1 error
Código-fonte:
import java.net.;
import java.io.;
import java.awt.;
import javax.swing.;
import java.awt.event.*;
public class Netinfo extends JFrame {
public JTextField texto1;
public JTextArea info;
public JLabel etiqueta;
public JButton ok;
public JScrollPane rolagem;
public URL url;
public Netinfo()
{
       etiqueta = new JLabel("URL:");
       texto1 = new JTextField(20);
       info = new JTextArea(20,20);
       info.setLineWrap(true);
       rolagem = new JScrollPane(info);
       JPanel painel = new JPanel();
       ok = new JButton("Ok");
       painel.add(etiqueta);
       painel.add(texto1);
       painel.add(ok);
       painel.add(rolagem);
       Container container = getContentPane();
       container.add(painel);
       setSize(200,200);
       setVisible(true);
       setLocation(300,300);
 }
public void getURL() throws Exception
{
    ok.addActionListener(new ActionListener() {
        
        
         public void actionPerformed(ActionEvent event)
         {
              url = new URL(texto1.getText());
               
             info.append(String.valueOf(url.getFile()));
             //info.setText(url.getPort());
             //info.append(url.getHost());
             //info.append(url.getRef());           
          
         }
        
    });
                          
 }
public static void main(String args[]) throws Exception
{
        Netinfo net = new Netinfo();
            net.getURL(); 
 }
}
Obrigado,
Marcelo Araujo

