import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class applet extends JFrame
{ JLabel l1;
public applet()
{
setSize(200,200);
l1=new JLabel();
l1.setToolTipText("sohu");
l1.setDisplayedMnemonic('0');
l1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
l1.setForeground(Color.red);
l1.setText("<html><body><a href=http://www.sohu.com>sohu</a></body></html>");
l1.setBounds(new Rectangle(50,50,80,30));
l1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseReleased(MouseEvent e)
{
try
{
Runtime.getRuntime().exec("cmd/c start http://www.sohu.com");
}
catch(Exception e1)
{
}
}
});
add(l1,null);
setLayout(null);
setVisible(true);
}
public static void main(String[] args)
{
new applet();
}
}
//我的希望是打开连接www.sohu.com的网页,怎么就是连接不上,忘高手指点
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class applet extends JFrame
{ JLabel l1;
public applet()
{
setSize(200,200);
l1=new JLabel();
l1.setToolTipText("sohu");
l1.setDisplayedMnemonic('0');
l1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
l1.setForeground(Color.red);
l1.setText("<html><body><a href=http://www.sohu.com>sohu</a></body></html>");
l1.setBounds(new Rectangle(50,50,80,30));
l1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseReleased(MouseEvent e)
{
try
{
Runtime.getRuntime().exec("cmd/c start http://www.sohu.com");
}
catch(Exception e1)
{
}
}
});
add(l1,null);
setLayout(null);
setVisible(true);
}
public static void main(String[] args)
{
new applet();
}
}
//我的希望是打开连接www.sohu.com的网页,怎么就是连接不上,忘高手指点
改为:
Runtime.getRuntime().exec("http://www.sohu.com");
改为
Runtime.getRuntime().exec("cmd /c start http://www.sohu.com");添置空格.