java applet未初始化小程序?
importjava.awt.*;importjava.applet.Applet;importjava.awt.event.*;publicclassItmeDemoe...
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class ItmeDemo extends Applet implements ItemListener
{
TextArea area=new TextArea(6,30);
String Uni[]={"Tsinghua university","Peking University","Nankai University","Chongqing University"};
Checkbox cb[]=new Checkbox[5];
Checkbox radio[]=new Checkbox[5];
public void init()
{
add(new Label("This is a Itme example"));
add(area);
add(new Label("Please choose the university you like:"));
for(int i=0;i<5;i++)
{
cb[i]=new Checkbox(Uni[i]);
add(cb[i]);
cb[i].addItemListener(this);
}
CheckboxGroup cbGroup=new CheckboxGroup();
add(new Label("please choose the university you like:"));
for(int i=0;i<5;i++)
{
radio[i]=new Checkbox(Uni[i],cbGroup,false);
add(radio[i]);
radio[i].addItemListener(this);
}
}
public void itemStateChanged(ItemEvent e)
{
area.append("you have chosen "+e.getItem()+"\n");
}
} 展开
import java.applet.Applet;
import java.awt.event.*;
public class ItmeDemo extends Applet implements ItemListener
{
TextArea area=new TextArea(6,30);
String Uni[]={"Tsinghua university","Peking University","Nankai University","Chongqing University"};
Checkbox cb[]=new Checkbox[5];
Checkbox radio[]=new Checkbox[5];
public void init()
{
add(new Label("This is a Itme example"));
add(area);
add(new Label("Please choose the university you like:"));
for(int i=0;i<5;i++)
{
cb[i]=new Checkbox(Uni[i]);
add(cb[i]);
cb[i].addItemListener(this);
}
CheckboxGroup cbGroup=new CheckboxGroup();
add(new Label("please choose the university you like:"));
for(int i=0;i<5;i++)
{
radio[i]=new Checkbox(Uni[i],cbGroup,false);
add(radio[i]);
radio[i].addItemListener(this);
}
}
public void itemStateChanged(ItemEvent e)
{
area.append("you have chosen "+e.getItem()+"\n");
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询