📄 choiceevt.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class ChoiceEVT extends Applet implements ItemListener
{
Choice choice1,choice2;
TextField text1,text2;
public void init()
{
setLayout (new GridLayout(2,2));
choice1=new Choice();
choice2=new Choice();
text1=new TextField(10);
text2=new TextField(10);
choice1.add("音乐天地");
choice1.add("武术天地");
choice1.add("象棋乐园");
choice1.add("交友聊天");
choice2.add("辽宁日报");
choice2.add("北京日报");
choice2.add("上海日报");
choice2.add("足球晚报");
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("小提琴曲:梁祝");
}
else if(choice1.getSelectedIndex()==1)
{
text1.setText("少林寺:少林拳");
}
else if(choice1.getSelectedIndex()==2)
{
text1.setText("和为贵");
}
else if(choice1.getSelectedIndex()==3)
{
text1.setText("知心朋友");
}
}
else if(e.getItemSelectable()==choice2)
{
if(choice2.getSelectedIndex()==0)
{
text2.setText("信息很好");
}
else if(choice2.getSelectedIndex()==1)
{
text2.setText("每天六版");
}
else if(choice2.getSelectedIndex()==2)
{
text2.setText("很难看到");
}
else if(choice2.getSelectedIndex()==3)
{
text2.setText("球迷天地");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -