lessonviewe.java

来自「看课程说明的小程序」· Java 代码 · 共 48 行

JAVA
48
字号
//<applet code = "lessonviewe.class" height = 100 width = 300></applet>
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class lessonviewe extends Applet implements ItemListener
{
	Choice choice;
	Label label;
	TextArea text;
	public void init()
	{
		setLayout(new BorderLayout());
		text = new TextArea(" ",10,10);
		choice = new Choice();
		choice.add("语文");
		choice.add("数学");
		choice.add("物理");
		choice.add("化学");
		add(choice);
		add("North",choice);
		add("Center",text);
		choice.addItemListener(this);
	}
	public void itemStateChanged(ItemEvent e)
	{
		if(e.getItemSelectable()==choice)
		{
			if(choice.getSelectedIndex()==0)
			{
				text.setText("chinese");
			}
			else if(choice.getSelectedIndex()==1)
			{
				text.setText("math");
			}
			else if(choice.getSelectedIndex()==2)
			{
				text.setText("physics");
			}
			else if(choice.getSelectedIndex()==3)
			{
				text.setText("chemistry");
			}
		}
	}
}
		

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?