下列Applet实现画一条连接窗口右上角的直线。选择正确的语句填入横线处。 import java.applet.*; import java.awt.*; public class ex25 extends Applet { public void paint (Graphics g) { Dimension d; d = getSize(); ______ } } ______ } }
A.g.drawLine(d.width, al.height, 0, 0);
B.g.drawLine(0, d.height, d.width, 0);
C.g.drawLine(0, 0, d. width, 0);
D.g.drawLine(0, d.height, 0, d.width);
第1题:
下列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());
第2题:
下列Applet实现了在Applet窗口中绘制一个以(70,70)为圆心,50为半径,边框为绿色的圆,圆心是红色的。选择正确的语句填入下面横线处。 import java.awt.*; import java.applet.*; public class ex20 extends Applet { public void paint(Graphics g) { g.setColor(Color. GREEN); g.drawOval(20, 20, 100, 100); g.setColor(Color. RED); ______ } }
A.g.drawOval(70, 70, 70, 70);
B.g.drawRect(70, 70, 1, 1);
C.drawRect(70, 70, 1, 1);
D.g.drawLine(70, 70, 1, 1);
第3题:
在编写Applet程序时,程序中必须有的import语句是
A.import.java.io.*;
B.import java.applet.Applet;
C.import.java.awt.event.*;
D.import.java.lang.*;
第4题:
下列Applet将已知char型数组各元素的值(设分别为65,66,70,80,67,78)显示在屏幕上。选择正确的语句填入横线处。 import java.awt.*; import java.applet.*; public class ex33 extends Applet { char a[] = {65, 66, 70, 80, 67, 78}; int j = 30; public void paint(Graphics g) { for(int i = 0; i <= a.length; i ++) { ______ += 25; } } }
A.g.drawString(a[i], j, 50);
B.drawString(Character, toString(a[i]), j, 50);
C.g.drawLine(Character, toString(a[i]),j, 50);
D.g.drawString(Character, toString(a[i]), j, 50);
第5题:
下列Applet实现了使用灰度值递减的顺序显示0~9,选择正确的语句填入横线处。 import java.applet.*; import java.awt.*; import java.awt.Color; public class ex24 extends Applet { public void paint(Graphics g) { int r = 0, g1 = 0, b = 0, j = 10; for(int i - 0; i < 10; i ++) { g.setColor(new Color(r, g1, b)); r += 25; g1 +=25; b +=25; j += 10; } } }
A.g.drawString(i, j, 30);
B.g.drawString("" + i, j, 30);
C.drawString(i,j, 30);
D.drawstring("" + i,j, 30);