package untitled1;
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;public class listtest extends Applet {public listtest() {
}public void init(){//在这里调用action1()就可以了。}
boolean action1(Event e,Object arg){//不能用action做函数名
List L=new List(4,true);
Button OK=new Button("确定");
L.addItem("北京");
L.addItem("天津");
L.addItem("上海");
L.addItem("杭州");
if(e.target instanceof Button){
if("确定".equals(arg)){
String [] selected=L.getSelectedItems();
for(int i=0;i<selected.length;i++){//selected拼写错误
System.out.println("您的选择为:"+selected[i]);
}
} }
else
System.out.println("Non-Event"); return true;
}}
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;public class listtest extends Applet {public listtest() {
}public void init(){//在这里调用action1()就可以了。}
boolean action1(Event e,Object arg){//不能用action做函数名
List L=new List(4,true);
Button OK=new Button("确定");
L.addItem("北京");
L.addItem("天津");
L.addItem("上海");
L.addItem("杭州");
if(e.target instanceof Button){
if("确定".equals(arg)){
String [] selected=L.getSelectedItems();
for(int i=0;i<selected.length;i++){//selected拼写错误
System.out.println("您的选择为:"+selected[i]);
}
} }
else
System.out.println("Non-Event"); return true;
}}
add(L);
add(OK);
//怎样来调用这个action1()
}