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

📄 listexample.java

📁 Java课程中所有的可运行程序 全部都是java课程中所涉及到的源码
💻 JAVA
字号:
import java.awt.event.*;
import java.awt.*;
 public class ListExample extends Frame{
List l1,l2;
TextField txt;
public ListExample(String ss){
super(ss);
setLayout(new FlowLayout());
	List l1=new List(3);
	l1.add("List1 no.1");
	l1.add("List1 no.2");
	l1.add("List1 no.3");
	l1.add("List1 no.4");
	l1.add("List1 no.5");
	l1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                l1_processAction(e);}
                  }  );
	add(l1);


	List l2=new List(4,true);
	l2.add("List2 no.1");
	l2.add("List2 no.2");
	l2.add("List2 no.3");
	l2.add("List2 no.4");
	l2.add("List2 no.5");
	l2.add("List2 no.6");
	l2.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                l2_processAction(e);}
                  }  );
	add(l2);

	txt=new TextField("此处显示选择结果............");
	add(txt);}

public void l1_processAction(ActionEvent e){
    if(e.getActionCommand()=="List1 no.1")
   {txt.setText("List 1 no.1 selected!");}
 if(e.getActionCommand()=="List1 no.2")
   {txt.setText("List 1 no.2 selected!");}
 if(e.getActionCommand()=="List1 no.3")
   {txt.setText("List 1 no.3 selected!");}
   if(e.getActionCommand()=="List1 no.4")
   {txt.setText("List 1 no.4 selected!");}
   if(e.getActionCommand()=="List1 no.5")
   {txt.setText("List 1 no.5 selected!");}
}


public void l2_processAction(ActionEvent e){
    if(e.getActionCommand()=="List2 no.1")
   {txt.setText("List 2 no.1 selected!");}
 if(e.getActionCommand()=="List2 no.2")
   {txt.setText("List 2 no.2 selected!");}
 if(e.getActionCommand()=="List2 no.3")
   {txt.setText("List 2 no.3 selected!");}
   if(e.getActionCommand()=="List2 no.3")
   {txt.setText("List 2 no.3 selected!");}
   if(e.getActionCommand()=="List2 no.4")
   {txt.setText("List 2 no.4 selected!");}
   if(e.getActionCommand()=="List2 no.5")
   {txt.setText("List 2 no.5 selected!");}
    if(e.getActionCommand()=="List2 no.6")
   {txt.setText("List 2 no.6 selected!");}
}


	 public static void main(String args[]) {
        ListExample nowFrame=new ListExample("ListExample ");
         nowFrame.addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent e){
    System.exit(0);
         }
  });
nowFrame.pack();
nowFrame.show();
    }



   }

⌨️ 快捷键说明

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