---
title: "2008-2009学年第 1 学期期末考试试题（ B  卷）（2）"
author: "lbsnm"
date: "2011-04-03T09:55:34Z"
tags: []
categories: ["编程语言"]
slug: "2008-2009-1-b-2"
draft: false
lastmod: "2011-11-22T11:34:59Z"
id: 985613
url: "https://lbsnm.iteye.com/blog/985613"
---

5、编写程序题（本题共20分）

1、编写一个Application程序：找出两个数中最小的数。

要求：此数据是从命令行参数得到，然后输出其中最大的数，如果没有参数输入或不够两个参数，显示“请输入两个命令行参数”，如果参数的个数多于两个，显示“命令行参数的参数个数多于两个” 。

 

 

2、编写程序实现窗口，包含一个标签、一个文本框和一个按钮，当用户单击按钮时，程序把文本框中的内容复制到标签中。（使用AWT）(根据提示在相应的位置填入正确的语句，标注（1）（2）（3）（4）的地方)。

 

//引入相关包

(1)

      public class MyFrame implements ActionListener

{

          Label lbl;

          TextField txt;

          Button btn;

         public MyFrame()

{

            Frame fr = new Frame();

            //设置窗体的布局为FlowLayout

            (2)           

            lbl = new Label("初始信息");

            txt = new TextField(30);

            btn = new Button("确定");

            fr.add(lbl);

            fr.add(txt);

            fr.add(btn);

            //给按钮注册监听器

            (3)

           //使用窗体可见，并设置大小

            (4)

         }            

        public void actionPerformed(ActionEvent e)

{

            lbl.setText(txt.getText());

}

public static void main(String args\[])

{

             new MyFrame();

}

}