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

题型:填空题

问题:

本题中,主窗口有一个按钮“打开对话框”和一个文本域,单击按钮“打开对话框”后会弹出一个对话框,对话框上有两个按钮“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 ActionListenet
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");

考点:计算机等级考试JAVA(A)二级JAVA笔试
题型:填空题

— What's the date today?

— It's November _____________.[ ]

A. 21th

B. 21st

C. 21nd

题型:填空题

对糖耐量曲线低平描述,正确的是()。

A.服糖后2h血糖仍处低水平

B.空腹血糖降低

C.服糖后2h血糖多在7.8~11.1mmol/之间

D.服糖后血糖上升不明显

E.空腹血糖轻度增高

题型:填空题

35kV油浸式变压器(电抗器)绕组对地电容变化大于5%,基本扣分为多少?()

A.2

B.4

C.8

D.10

题型:填空题

在晶闸管变流装置与直流电动机组成的直流调速系统中,采用多台变流器共用1台整流变压器时,每台变流器分别通过进线电抗器供电,这时进线电抗器的电感量应满足:当变流器输出额定电流时,进线电抗器绕组上的电压降应不低于供电电源额定相电压的( )。

A.4%
B.3%
C.2%
D.1%

题型:填空题

上消化道出血,伴有发热及右上腹痛,应考虑()

A.胃、十二指肠溃疡病

B.门静脉高压症

C.出血性胃炎

D.胃癌

E.胆道出血

更多题库