编译好的java 程序不能运行,惨惨惨!!!!!.请教各位!!(在线) applet小应用程序需要使用appletviewer来看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 需要你写个html,里面调用applet的 1、Applet要用appletviewer和浏览器看2、源代码中有一点错误3、源代码//example.java :import java.applet.*;import java.awt.*;import java.awt.event.*;public class example extends Applet implements ItemListener{ Choice choice1,choice2; TextField text1=new TextField(),text2=new TextField(); public void init() { setLayout(new GridLayout(2,2)); choice1=new Choice(); choice2=new Choice(); choice1.add("Music Hall"); choice1.add("Wushu Palace"); choice1.add("Chess Garden"); choice1.add("Chart"); choice2.add("Liaoling Daily"); choice2.add("BeiJing Daily"); choice2.add("Shanghai Daily"); choice2.add("Football Papar"); add(choice1); add(choice2); add(text1); add(text2); choice1.addItemListener(this); choice2.addItemListener(this); } public void itemStateChanged(ItemEvent e) { if (e.getItemSelectable()==choice1) { if(choice1.getSelectedIndex()==0) {text1.setText("violin:The Died Bufferfly");} else if(choice1.getSelectedIndex()==1) {text1.setText("ShaoLinsi:Shaolin boxing");} else if(choice1.getSelectedIndex()==2) {text1.setText("Friendship");} else if(choice1.getSelectedIndex()==3) {text1.setText("Heart Friends");} } else if(e.getItemSelectable()==choice2) { if(choice2.getSelectedIndex()==0) {text2.setText("Good Information");} else if(choice2.getSelectedIndex()==1) {text2.setText("Six Everyday");} else if(choice2.getSelectedIndex()==2) {text2.setText("Hard to see");} else if(choice2.getSelectedIndex()==3) {text2.setText("Ball Fans Club");} } } }4、编译F:\java>javac example.java5、写web.html文件,文件和类文件在同一目录中<HTML><appletcode=examplewidth=300height=200></applet></HTML>6、用appletviewer看或直接用浏览器看F:\java>appletviewer web.html 运行后appletviewer 显示:未初始化小应用程序!!!还是不能显示列表匡!!怎么办?谢谢指教!! 我试了一下可以呀,这种错误没有找到CLASS文件,你按照上面的方法一步一步来应该不会有错。 Java程序发声 spring(2.5)和struts2(2.0.14)集成问题!跪求高手指教! 请问JAVA能写病毒吗 请问文件对话框和消息框分别是哪个类? new 直接调用方法 的问题 求教 java能否printf出 汉字或字母的计算机内的二进制表示。 一个很弱智的问题,请各位大大帮帮忙 JBuilder运行时的问题 求实体bean的例子 谁能教教我怎样使用jdb? 对经过混淆的java程序的反编译 请网友谈谈解决方法,散分!!! jsp的scope属性!
2、源代码中有一点错误3、源代码
//example.java :import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class example extends Applet implements ItemListener
{ Choice choice1,choice2;
TextField text1=new TextField(),text2=new TextField();
public void init()
{
setLayout(new GridLayout(2,2));
choice1=new Choice();
choice2=new Choice();
choice1.add("Music Hall");
choice1.add("Wushu Palace");
choice1.add("Chess Garden");
choice1.add("Chart");
choice2.add("Liaoling Daily");
choice2.add("BeiJing Daily");
choice2.add("Shanghai Daily");
choice2.add("Football Papar");
add(choice1);
add(choice2);
add(text1);
add(text2);
choice1.addItemListener(this);
choice2.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
if (e.getItemSelectable()==choice1)
{
if(choice1.getSelectedIndex()==0)
{text1.setText("violin:The Died Bufferfly");}
else if(choice1.getSelectedIndex()==1)
{text1.setText("ShaoLinsi:Shaolin boxing");}
else if(choice1.getSelectedIndex()==2)
{text1.setText("Friendship");}
else if(choice1.getSelectedIndex()==3)
{text1.setText("Heart Friends");}
}
else if(e.getItemSelectable()==choice2)
{
if(choice2.getSelectedIndex()==0)
{text2.setText("Good Information");}
else if(choice2.getSelectedIndex()==1)
{text2.setText("Six Everyday");}
else if(choice2.getSelectedIndex()==2)
{text2.setText("Hard to see");}
else if(choice2.getSelectedIndex()==3)
{text2.setText("Ball Fans Club");}
}
}
}4、编译
F:\java>javac example.java5、写web.html文件,文件和类文件在同一目录中
<HTML>
<applet
code=example
width=300
height=200>
</applet>
</HTML>6、用appletviewer看或直接用浏览器看
F:\java>appletviewer web.html
应该不会有错。