itgle.com

Whatwillbetheappearanceofanappletwiththefollowinginit()method?publicvoidinit(){add(newButton("hello"));}A.Nothingappearsintheapplet.B.Abuttonwillcoverthewholeareaoftheapplet.C.Abuttonwillappearinthetopleftcorneroftheapplet.D.Abuttonwillappear,centeredinth

题目
Whatwillbetheappearanceofanappletwiththefollowinginit()method?publicvoidinit(){add(newButton("hello"));}

A.Nothingappearsintheapplet.

B.Abuttonwillcoverthewholeareaoftheapplet.

C.Abuttonwillappearinthetopleftcorneroftheapplet.

D.Abuttonwillappear,centeredinthetopregionoftheapplet.

E.Abuttonwillappearinthecenteroftheapplet.


相似考题
更多“Whatwillbetheappearanceofanappletwiththefollowinginit()method?publicvoidinit(){add(newButton("hello"));} ”相关问题
  • 第1题:

    阅读下面代码:

    import java.awt.*;

    public class Exam11_1

    {

    private Frame. f;

    private Button b1,b2,b3,b4;

    public static void main(String args[]

    {

    Exam11_1 that = new Exam11 1 ();

    that.go();

    }

    public void go()

    {

    ______;

    f.setLayout(new FlowLayout()) ;;

    b1 = new Button ("Button 1");

    b2 = new Button ("Button 2");

    b3 = new Button ("Button 3");

    b4 = new Button ("Button 4");

    f.add (b1);

    f.add (b2);

    f.add (b3);

    f.add (b4);

    f.pack ();

    f.setVisible (true);

    }

    }

    请在程序中画线处填写正确的语句【 】,以便编译运行程序后得到正确的结果。


    正确答案:f=new Frame("GUI example")
    f=new Frame("GUI example") 解析:本题考查容器和布局管理器的基本知识,属于综合题。在本程序里,缺少建立Frame的语句,而且该Frame的名字为GUI example,而4个按钮的布局方式被压缩至最小,因此是 FlowLayou布局方式。

  • 第2题:

    下列程序在Frame中设定BorderLayout布局管理器,选择正确的语句填入程序的横线处。 import java.awt.*; public class ex43 extends Frame { public static void main(String[] args) { ex43 bj = new ex43("BorderLayout"); ______ obj.add("North", new Button("North")); obj.add("South", new Button("Sourth")); obj.add("East", new Button ("East")); obj.add("West", new Button ("West")); obj. add ("Center", new Button ( "Center" ) ); obj.pack(); obj. setVisible (true); } public ex43(String str) { super (str); } }

    A.obj.setLayout(new BorderLayout());

    B.setLayout(new Borderkayout());

    C.setLayout(BorderLayout());

    D.obj.setLayout(BorderLayout());


    正确答案:A

  • 第3题:

    下列Applet在窗口中放置2个Button,标签分别为“东”和“西”,在窗口中的位置与它们的名字相同。选择正确的语句填入横线处。 import java.awt.*; import java.applet.*; public class ex16 extends Applet { Button e, w; public void init() { e = new Button("东"); w = new Button("西"); add("East", e); add("West", w); } }

    A.setLayout(new BoxLayout());

    B.setLayout(new FlowLayout());

    C.setLayout(new BorderLayout());

    D.setLayout(new GridLayout());


    正确答案:C

  • 第4题:

    请将下列程序的空白处补充完整。

    Importjava.awt.*;

    PublicclassEll_4

    {

    Publicstaticvoidmain(Stringargs[])

    {

    Framef=newFrame(“BorderLayout”);

    fiadd(“North”,newbuRon(“North”));

    f.add(“East”,newbutton(“East”));

    f.add(“West”,newbutton(“West”));

    f.add(“South”,tf);

    f.setSize(200,200)

    fipack();

    fisetVisible(true);

    }

    }


    正确答案:TextField if=llew TextField("Text");
    TextField if=llew TextField("Text"); 解析: 本题考查java中常用组件的创建。由题可知,创建的是3个按键和1个文本框,tf为该文本框。

  • 第5题:

    下列程序采用BorderLayout布局管理,选择正确的语句填入横线处,实现在North区域显示一个名字为“北方”的Button构件。 import java.awt.*; public class ex48 { public static void main(String[] args) { frame. frm = new Frame. ("北方"); frm.setLayout(new BorderLayout()); frm.setSize(200, 200); frm.setVisible(true); } }

    A.add("Nouth", new Button("北方"));

    B.frm.add("South", new Button("北方"));

    C.frm.add("Nouth", new Button("北方"));

    D.Frm.add("South", Button("北方"));


    正确答案:C