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

📄 example7_20.java.bak

📁 不错的教程 适合中高级人员的使用
💻 BAK
字号:
import java.awt.*;import java.awt.event.*;
 class WindowChoice extends Frame implements
ItemListener,ActionListener
{  Choice choice; 
   TextField text;
   TextArea area;
   Button add,del;
   WindowChoice()
   {  setLayout(new FlowLayout());
	   choice=new Choice(); 
      text=new TextField(8);
      area=new TextArea(6,15);  
      choice.add("音乐天地"); 
      choice.add("武术天地");
      choice.add("象棋乐园");     
      choice.add("交友聊天");
      add=new Button("添加");
      del=new Button("删除");
      add.addActionListener(this);del.addActionListener(this);
      choice.addItemListener(this);
      add(choice);  
      add(del);add(text);add(add);add(area);
	  setSize(200,200);
	 setVisible(true);
	 validate();
   }
   public void itemStateChanged(ItemEvent e)
   {  String name=choice.getSelectedItem();
      int index=choice.getSelectedIndex();
      area.setText("\n"+index+":"+name);
   }
   public void actionPerformed(ActionEvent e)
   {  if(e.getSource()==add||e.getSource()==text)
        {  String name=text.getText();
           if(name.length()>0)
              {  choice.add(name);
                 choice.select(name);
                 area.append("\n添加"+name);
              }
        }
      else if(e.getSource()==del)
        {  choice.remove(choice.getSelectedIndex());
           area.append("\n删除"+choice.getSelectedItem());
        }
   }
} 
public class Example7_20
{
	public static void main(String args[])
	{
		new WindowChoice();
	}
}

⌨️ 快捷键说明

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