下面是生成一个依赖窗口的对话框,属性为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();
举一反三
- 以下代码运行后外观为?( )import java.awt.*; public class CompLay extends Frame{ public static void main(String argv[]){ CompLay cl = new CompLay(); } CompLay(){ Panel p = new Panel(); p.setBackground(Color.pink); p.add(new Button("One")); p.add(new Button("Two")); p.add(new Button("Three")); add("South",p); setSize(300,300); setVisible(true); } } A: 按钮按从左向右的次序出现在窗体的底部 B: 按钮按从左向右的次序出现在窗体的顶部 C: 按钮将不显示 D: 只有一个按钮显示占满整个窗体
- (7-1)以下程序的运行结果是( )。 class A{ A(){ System.out.print(10); } } public class Demo extends A { public static void main(String[] args) { new A(); new Demo(); } }
- 下面哪个语句是正确的 ( ) A: Object o=new Button("A"); B: Button b=new Object("B"); C: Panel p=new Frame(); D: Frame f=new Panel();
- 下面哪个语句是正确的( ) A: Object o=new Button(″A″); B: Panel p=new Frame(); C: Frame f=new Panel(); D: Button b=new Object(″B″);
- 阅读程序题(给出【代码】注释标注的代码的输出结果)interface Com {int add( int a, int b);}abstract class People {abstract int add( int a, int b);}class Student extends People implements Com{public int add(int a,int b) {return a + b;}}public class 习题5_阅读3 {public static void main(String args[ ]) {Student stu = new Student ();Com com = stu;int m = com.add(12,6);People p = stu;int n = p.add(12,8);System.out.printf("%d:%d",m,n); //【代码】}}