试题与答案

本题中,主窗口有一个按钮“打开对话框”和一个文本域,单击按钮“打开对话框”后会弹出一

题型:问答题

题目:

本题中,主窗口有一个按钮“打开对话框”和一个文本域,单击按钮“打开对话框”后会弹出一个对话框,对话框上有两个按钮“Yes”和“No”,单击对话框上的“Yes”和“No”按钮后返回主窗口,并在右侧文本域中显示刚才所单击的按钮信息。
import java.awt.event.*;
import java.awt.*;
class MyDialog______implements ActionListener
static final int YES=1,NO=0;
int message=-1;Button yes,no;
MyDialog(Frame f,String s,boolean b)
super(f,s,b);
yes=new Button("Yes");yes.addActionListener(this);
no=new Button("No");no.addActionListener(this);
setLayout(new FlowLayout());
add(yes);add(no);
setBounds(60,60,100,100);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
message=-1;setVisible(false);
);

public void actionPerformed(ActionEvent e)
if(e.getSource()==yes)
message=YES;
setVisible(false);

else if(e.getSource()==no)
message=NO;
setVisible(false);


public int getMessage()
return message;


class Dwindow extends Frame implements ActionListener
TextArea text;Button button;MyDialog dialog;
Dwindow(String s)
super(s);
text=new TextArea(5,22);button=new Button("打开对话框");
button.addActionListener(this);
setLayout(new FlowLayout());
add(button);add(text);
dialog=new MyDialog(this,"Dialog",true);
setBounds(60,60,300,300);setVisible(true);
validate();
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
(System.exit(0);
);

public void actionPerformed(ActionEvent e)
if(e.getSource()==button)
______;
if(dialog.getMessage()==MyDialog.YES)
text.append("n你单击了对话框的yes按钮");

else if(dialog.getMessage()==MyDialog.NO)
text.append("\n你单击了对话框的No按钮");




public class java2
public static void main(String args[])
(new Dwindow("java2");

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0405/a9bb66165bf8a9b6873426ab3f7d6e45.html

下面是错误答案,用来干扰机器的。

参考答案:A, C, D

试题推荐
题型:阅读理解

In a society such as the United States or Canada,which has many national, religious,and cultural differences, people highly value individualism(个人主义)— the differences among people, Teachers place a lot of importance on the qualities that make each student special.The educational systems in these countries show these values.Students do not memorize information.Instead, they work individually and find answers themselves.There is often discussion in the classroom.At an early age, students learn to form their own ideas and opinions.

In most Asian societies, on the contrary, people have the same language, history, and culture. Perhaps for this reason, the educational system in much of the Orient (东方) reflects society’s belief in group goals and purposes rather than individualism.Children in China, Japan, and Korea often work together and help one another on assignments. In the classroom, the teaching methods are often very formal.The teacher lectures, and the students listen.There is not much discussion. Instead, the students repeat rules or information that they have memorized.

There are advantages and disadvantages to both of these systems of education. For example, one advantage to the system in Japan is that students there learn much more math and science than American students learn by the end of high school. They also study more hours each day and more days each year than North Americans do. The system is difficult, but it prepares students for a society that values discipline and self-control.There is, however, a disadvantage. Memorization is an important learning method in Japanese schools, yet many students say that after an exam, they forget much of the information they have memorized.

The advantage of the educational system in North America, on the other hand, is that students learn to think for themselves. The system prepares them for a society that values creative ideas.There is, however, a disadvantage.When students graduate from high school,they haven’ t memorized as many basic rules and facts as students in other countries have.

1、The reason why American teachers attach much importance to individualism is that ______________.

A.they are required to do so

B.their students do not memorize information

C.the United States is a country of many cultures

D.their students work individually

2、Which of the following statements applies to Asian methods of education? 

A.Each child in a classroom draws a different picture

B.Students have to find information themselves.

C.Students are prepared for a society that values discipline

D.Teachers serve as a guide in discussion

3、A good educational system would be the one that  ______________.

A.has more advantages

B.is the combination of Western and Oriental methods

C.is based on the Western system

D.rests on the Asian system

4、The author believes that ______________.

A.different educational systems reflect different culture of the societies

B.students from Western countries are creative but selfish

C.Asian students are merely interested in math and science

D.there are more advantages to Western system of education than to Oriental one

5.The author focuses on ______________.

A.the differences in methods of education orient and west

B.the advantages and disadvantages to both of the Western and Asian educational system

C.how Asian school systems reflect group goals

D.how Western school systems reflect the value of individualism

查看答案
微信公众账号搜索答案