?? xlcd.java
字號:
import java.awt.*;
import java.awt.*;
public class Xlcd extends java.applet.Applet implements
ItemListener,ActionListener
{
Choice choice;
TextField text;
TextArea area;
Button add;
Button del;
public void init()
{ setLayout(new GridLayout(3,1));
choice=new Choice();
text=new TextField(12);
area=new TextArea("S",20,10,TextArea.SCROLLBARS_BOTH);
add=new Button("添加");
del=new Button("刪除");
choice.add("音樂天地");
choice.add("清華大學");
choice.add("北京大學");
choice.add("學友之旅");
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
add(p1,"North");
add(p2,"Center");
add(p3,"South");
p1.add(choice);
p1.add(del);
p2.add(text);
p2.add(add);
p3.add(area);
choice.addItemListener(this);
add.addActionListener(this);
del.addActionListener(this);
}
public void itemStateChanged(ItemEvent e)
{
String name=choice.getSelectedItem();
int index=choice.getSelectedIndex();
area.setText("\n"+index+":"+name+"\n");
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==add||e.getSource()==text)
{
String str=text.getText();
if(str.length()>0)
{
choice.add(str);
area.append("\n"+"增加"+str);
choice.select(str);
}
}
if (e.getSource()==del)
{String st=choice.getSelectedItem();
choice.remove(st);
area.append("\n"+"刪除"+st);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -