⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e5_15x.java

📁 java 初学者学习实例
💻 JAVA
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class E5_15x 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);
		choice1.addItemListener(this);
		add(choice1);add(choice2);
		choice2.addItemListener(this);
		add(text1);add(text2);
		
	}
   	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 + -