这个java小应用程序为什么运行不出来?
importjava.awt.*;importjava.awt.event.*;importjava.applet.*;publicclasstrychoiceexten...
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class trychoice extends Applet{
String[] abc={"red","bule","yellow","orange","grey","green","black"};
TextArea t=new TextArea(5,6);
Choice c=new Choice();
public void init()
{
t.setEditable(false);
for(int i=0;i<8;i++)
c.addItem(abc[i]);
add(t);
add(c);
c.addItemListener(new CL());
}
class CL implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
t.append("\n"+"index:"+c.getSelectedIndex()+"\n"+c.getSelectedItem()+"is selected");
}
}
} 展开
import java.awt.event.*;
import java.applet.*;
public class trychoice extends Applet{
String[] abc={"red","bule","yellow","orange","grey","green","black"};
TextArea t=new TextArea(5,6);
Choice c=new Choice();
public void init()
{
t.setEditable(false);
for(int i=0;i<8;i++)
c.addItem(abc[i]);
add(t);
add(c);
c.addItemListener(new CL());
}
class CL implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
t.append("\n"+"index:"+c.getSelectedIndex()+"\n"+c.getSelectedItem()+"is selected");
}
}
} 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询