btnOpen.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
try{
URL url=new URL("http://dymeteo.com");
Applet1.this.getAppletContext().showDocument(url,"_BLANK");
}catch(java.net.MalformedURLException malE){}
}
});
public void mouseClicked(MouseEvent e){
try{
URL url=new URL("http://dymeteo.com");
Applet1.this.getAppletContext().showDocument(url,"_BLANK");
}catch(java.net.MalformedURLException malE){}
}
});
用wfc可能可以。
try
{
rs.exec("iexplore http://www.sohu.com");
}catch(Exception e){}
try
{
rs.exec("iexplore http://www.sohu.com");
}catch(Exception e){}
import java.awt.*;
import java.net.*;
import java.applet.Applet;
public class SiteSelector extends Applet{
Site siteList[];
public void init()
{
siteList=new Site[2];
siteList[0]=new Site("Java Union","http://www.deping.net/index.html");
siteList[1]=new Site("Tom web","http://www.tom.com/index.html");
for (int i=0;i<siteList.length;i++) add(new Button (siteList[i].getTitle()));
}
public boolean action (Event e,Object arg)
{
if (e.target instanceof Button){
String title;
URL location;
for (int i=0;i<siteList.length;i++){
title=siteList[i].getTitle();
location=siteList[i].getLocation();
if(title.equals(arg.toString())){
gotoSite(location);
return true;
}
}
}
return false;
}
public void gotoSite(URL loc){
getAppletContext().showDocument(loc );
}
}
public class Site extends Button{
private String title;
private URL location;
public Site(String siteTitle,String siteLocation)
{
title=siteTitle;
try{
location=new URL(siteLocation);
}
catch(MalformedURLException e){
System.err.println("Invalid URL:" + siteLocation);
}
}
public String getTitle(){
return title;}
public URL getLocation(){
return location;}
}
------------------------------------------------------------------------------
好像不能通过,说Site类未找到
大虾们帮我看看!
import java.awt.event.*;
public class exec extends Frame
{
Button t =new Button("run program");
public exec()
{
add(t);
t.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try{
Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE www.csdn.net");
}
catch(Exception ee)
{}
}
});
}
public static void main(String args[])
{
exec t=new exec();
t.setSize(400,400);
t.setVisible(true);
}}