[填空题] 下面是生成一个依赖窗口的对话框,属性为modal,请把所缺的代码补齐。 import java.awt.*; public class DialogDemo extends Frame

12 查阅

[填空题] 下面是生成一个依赖窗口的对话框,属性为modal,请把所缺的代码补齐。

import java.awt.*;

public class DialogDemo extends Frame

DialogDemo ( )

SetTitle ("Demo");

Panel p=new Panel();

p.add(new label ("one"));

p.add(new Checkbox("two"));

add ("North",p);

add ("Center", new TextArea ("three", 3,10));

Dialog d=new Dialog(this,"a cat", 【12】 );

d.add("North",new Label ("Modal dialog");

d.add("Center",new TextArea("hello");

d.pack ();

d.show();

public static void main(String args[] )

DialogDemo f=new DialogDemo();

f.pack();

f.show ();

参考答案:

true

本题是考查对话框的有关属性和使用方法。Dialog是Window的子类,它表示一个对话窗口。与Frame不同,它的存在依赖于其他窗口,当它所依赖的窗口被关闭时,对话框也消失。当指定的对话框为modal,这时当对话框出现时,用户只能对它进行操作,而不能对其他窗口进行操作。Dialog的构造方法如下 Dialog(Frame parent,Boolean modal); Dialog(Frame parent,String title,Boolean modal);

计算机考试