问题 填空题

请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
[题目要求]
生成下面左边图形界面,单击图中的New按钮,弹出如右图所示的对话框。


源程序:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Java_3
 public static void main(String[] args)
  MulticastFrame frame=new MulticastFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.show();
 

class MulticastFrame extends JFrame
 public MulticastFrame()
  setTitle("MulticastTest");
  setSize(WIDTH,HEIGHT);
  MulticastPanel panel=new MulticastPanel();
  Container contentPane=getContentPane();
  contentPane.add( (1) );
 
 public static final int WIDTH=300;
 public static final int HEIGHT=200;

class MulticastPanel extends JPanel
 public MulticastPanel()
  JButton newButton=new JButton("New");
  add(newButton);
  ActionListener newListener=new ActionListener()
    public void actionPerformed(ActionEvent event)
      makeNewFrame();
    
  ;
  newButton.addActionListener(newListener);
  closeAllButton=new JButton("Close all");
  add(closeAllButton);

private void makeNewFrame()
  final BlankFrame frame=new BlankFrame();
  frame.show();
  ActionListener closeAllListener=new ActionListener()
    public void actionPerformed(ActionEvent event)
      frame. (2) (); //使窗口隐藏或消除
    
  ;
  closeAllButton.addActionListener( (3) );
 
 private JButton closeAllButton;

Class BlankFrame extends JFrame
 public BlankFrame()
   (4) ++;
  setTitle("Frame"+counter);
  setSize(WIDTH,HEIGHT);
  setLocation(SPACING*counter,SPACING*counter);
 
 public static final int WIDTH=200;
 public static final int HEIGHT=150;
 public static final int SPACING=30;
 private static int counter=0;

答案

参考答案:hide

解析: 通过注释和程序,可以看出此处要将窗口隐藏,通常窗口的隐藏和显示采用setvisible()方法,但是此处方法没有参数,所以可以使用方法hide(),只是hide()方法在JDK5开始被setVisible()方法取代。

阅读理解

Jessie felt her life so boring one summer day. She was so tired of watching TV, she read all her books, and her friends were on vacation. She wanted something different to do. Suddenly, she saw the lawn mower(割草机) sitting in the yard.

“ Mom,” she shouted, “ I think I will mow the lawn.” Her mom ran into the yard and said, “ Oh no, you don’t. You’re too young to mow the lawn.”

I’m fourteen years old and know how to do it,” Jessie said, “ Besides, it would help Dad out, and he won’t have to worry about it over the weekend.”

Mom thought for a while and then decided to let Jessie give it a try. After all, she was home and would keep an eye on her. Jessie already knew how to start the lawn mower from watching her dad. Jessie checked the gas(汽油) to make sure it was full, and put on her gardening gloves to protect her hands. Mom watched from the kitchen window. Jessie really does know how to mow the lawn. She was very careful around the flowers and trees. When she finished, she felt so good,but she was so hot. Mom brought her some ice tea and said, “You sure did a great job. Dad will be very surprised.”

Later that day, Dad came home and said to Jessie’s mom, “You didn’t have to mow the lawn. I was going to do it on Saturday. It looks great. Thanks.”

I didn’t mow it. Jessie did.”

“Wow,our little girl is growing up!” Dad told Jessie what a great job she had done.

“It was fun, and I will do it again next week,” said Jessie.

The neighbor next door came by and asked Jessie if she wanted to mow his lawn and make some money. “Sure!” said Jessie. Jessie began mowing his lawn. Two other neighbors asked so, then another three. Jessie was now mowing lawns for them all and making some money. She was no longer bored! “I won’t have time to spend my money,” she laughed to herself.

小题1:In order to do something different, Jessie decided to ________.

A.read the books

B.travel

C.mow the lawn

D.watch TV小题2:What does “keep an eye on” mean?

A.保护

B.注视

C.培养

D.瞄准小题3:Bofore Jessie mowed the lawn, she ________.

A.washed her hands

B.bought some gas

C.read some instructions

D.put on her gloves小题4:How did Jessie’s father feel when he knew Jessie had mowed the lawn?

A.Proud

B.Angry

C.Relaxed

D.Worried小题5:What does the text mainly tell us?

A.Neighbors should learn to help each other.

B.Mowing the lawn is a good way to make money.

C.Doing something helpful can make people happy.

D.Children should help their parents at an early age.

多项选择题 案例分析题