📄 choice1.java
字号:
//:Choicel.java
// Using drop-down lists
import java.awt.*;
import java.applet.*;
public class Choice1 extends Applet {
String[] description={"Ebullient","Obtuse",
"Recalcitrant","Brilliant","Somneacent",
"Timorous","Florid", "Putrescent"};
TextField t=new TextField(30);
Choice c=new Choice();
Button b=new Button("add items");
int count =0;
public void init() {
t.setEditable(false);
for(int i =0;i < 4; i++)
c.addItem(description[count++]);
add(t);
add(c);
add(b);
}
public boolean action (Event evt,Object arg) {
if(evt.target.equals(c))
t.setText("index: " + c.getSelectedIndex()
+ " " +(String)arg);
else if(evt.target.equals(b)) {
if(count < description.length);
c.addItem(description[count++]);
}
else
return super.action(evt,arg);
return true;
}
}
// <applet code=Choice1.class width=250 height=100></applet>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -