image是要绘制的图像
x,y是表示图像的中心的位置
width是源图像的宽度
this是容器
第1题:
下面Applet程序的功能是统计在平面坐标系第一象限中,半径大于9,小于10的圆环中坐标值为整数的点有多少?并且给出其坐标值。请改正程序中的错误(有下画线的语句),使程序执行后,能得到预期的结果。
import java.awt.*;
import java.applet.*;
/*
<applet code=Di9Ti width=200 height=100>
</applet>
*/
public class Di9Ti extends Applet
{
public void paint(Graphics g)
{
int x,y,r1=5,r2=4;
int count=0;
for(x=1;x<y;x++)
{
for(y=1;y<r1;y)
{
if(x*x+y*y<=r2*r2||x*x+y*y>=r1*r1)
break;
g.drawStdng("x="+x+"y="+y,20+count*80,20);
count++;
}
}
g.drawString("count="+count,20,40);
}
}
ex11_3.html:
<html>
<head>
<title>A Simple Program</title>
</head>
<body>
<applet code="Di9Ti.class"width=800 height=400>
</applet>
</body>
</html>
第2题:
下面是一个Applet程序,其功能是绘制三维矩形以使该矩形面凹下,并将图像放入凹下的矩形面中。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
源程序文件代码清单如下:
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
import java.util.*;
import java.net.*;
/*
<applet code="ex01_3.class"width=800 height=400>
</applet>
*/
public class ex01_3 extends Applet
{
private Image IMG nClick=over(this) title=放大;
public void init()
{
URL url=getCodeBase();
IMG nClick=over(this) title=放大=getImage(url,"ex01_3.gif");
MediaTracker mt=new MediaTracker();
mt.addImage(IMG nClick=over(this) title=放大,1);
try
{
mt.waitForAll();
} catch(Exception e)
{
e.printStackTrace();
}
setBackground(Color.black);
}
public void paint(Graphics g)
{
int thick=3,x=10,y=10;
g.drawImage(IMG nClick=over(this) title=放大,x,y);
g.setColor(Color.lightGray);
int w = IMG nClick=over(this) title=放大.getWidth(this);
int h = IMG nClick=over(this) title=放大.getHeight(this);
for(int i=0;i<thick;i++)
g.draw3DRect(x,y,w+(a*i),true);
}
}
ex01 3.html
<HTML>
<HEAD>
<TITLE>ex01_3</TITLE>
</HEAD>
<BODY>
<applet code="ex01_3.class"width=800 height=400>
</applet>
</BODY>
</HTML>
第3题:
在CSS语言中下列哪一项是"列表样式图象"的语法()。
A.width:
B.height:
C.white-space:
D.list-style-image:
第4题:
要向Applet传递参数,应该在下列drawing.html文件的下画线处填人的选项是( )。 … … <applet code=Drawlmage.class width=1 00 height= 100> </applet> … …
A.<param image,"flower.gif">
B.<param image value=flower.gif>
C.<param name=image value="flower.gif">
D.<param name="image"value="flower.gif">
第5题:
●试题七
【说明】
下面是一个Applet程序,其功能是将完整的图像显示于Applet的区块中,然后可以通过拖动鼠标让图像随着鼠标拖动的轨迹而移动。
程序运行结果如图5所示。

图5
import java.applet.*;
import java.awt.*;
/*
<applet code="ex4_7.class" width=800 height=400 >
</applet>
*/
public class ex4_7 extends Applet{
private Image iImg;
private int xPos,yPos;
public void init(){
xPos = yPos =(1);
iImg = getImage((2)"ex4_7.jpg");
}
public void paint(Graphics g){
g.drawImage(iImg,xPos,yPos,(3));
}
public boolean(4)(Event e,int x,int y){
xPos = x;
yPos = y;
(5);
return true;
}
}
ex4_7.html
<HTML>
<HEAD>
<TITLE>ex4_7</TITLE>
</HEAD>
<BODY>
<applet code="ex4_7.class" width=800 height=400 >
</applet>
</BODY>
</HTML>
●试题七
【答案】(1)0(2)getDocumentBase()
(3)this
(4)mouseDrag
(5)repaint()
【解析】本题主要考查在Applet窗口中显示图像,并结合鼠标事件处理的综合应用。解题关键是熟悉图像文件的加载过程,会跟踪鼠标拖动的事件,并将鼠标在Applet窗口中的坐标信息作为参数传递给drawImage()方法,用于在新的位置显示图像,从而实现拖动效果。本题中,getImage()方法应该有2个参数,第一个参数是getDocumentBase()方法的返回值,即图像文件的路径;drawImage()方法最后一个参数应该是this,确定是在当前运行的对象中绘制图像;应该调用repaint()方法,进行重画,而不是paint()方法。
第6题:
关于图片大小的设置,以下说法正确的是()。
第7题:
组件的setSize()方法签名正确的是哪项?()
第8题:
图像在网页显示的代码正确的是()
第9题:
以下关于width属性和height属性语法格式正确的是()。
第10题:
You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application that displays a high-resolution graphic image named Image1.jpg. You need to limit the width of the image to 200 pixels. You also need to preserve the aspect ratio of the image. Which code fragment should you use?()
第11题:
image是要绘制的图像
x,y是表示图像的中心的位置
width是源图像的宽度
this是容器
第12题:
#box{width:100px;height:50px;}
#box{width:100px;height:50px; position:absolute;}
#box{width:100px;height:50px; position:static;}
#box{width:100px;height:50px; position:relative;}
第13题:
以下代码片断中,属于绝对定位的是()。
A、#box{width:100px;height:50px;position:absolute;}
B、#box{width:100px;height:50px;position:static;}
C、#box{width:100px;height:50px;position:relative;}
D、#box{width:100px;height:50px;}
第14题:
下面是一个Applet程序,程序的功能输出一个彩色窗体。请改正程序中的错误(有下划线的语句),使程序能输出正确结果。
注意:不改动程序的结构,不得增行或删行。
程序的输出结果为:

import java.awt.*;
import java.awt.image.*;
import java.applet.Applet;
public class MemoryImage extends Applet
{
Image IMG nClick=over(this) title=放大;
public void init()
{
Dimension d=getSize();
int w=d.width,h=d.height;
int pix[ ]=new int[w*h];
int index=0;
for(int y=0;y<h;y++)
for(int x=0;x<w;x++)
{
int red=(x|y)&&0xff;
int green=(x*2|y*2)&0xff;
int blue=(x*4|y*4)&0xff;
pix[index++]=(255<<24)|(red<<16)|(green<<8)|blue;
}
IMG nClick=over(this) title=放大=createImage(new FilteredImageSource(w,h,pix, 0,w));
}
public void paint(Graphics g)
{
g.drawImage(IMG nClick=over(this) title=放大, 0,0,super);
}
}
ex36_3.html:
<html>
<head>
<title>A Simple Program</title>
</head>
<body>
<applet code=" MemoryImage.class" width=800 height=400>
</applet>
</body>
</html>
第15题:
有关绘图,下面的说法正确的是( )。 Ⅰ:drawArt(int x,int y,int width,int height,ing stanAngle,int arcAngle)是用来指定在矩形的边界内从起始角度到结束角度之间画弧。 Ⅱ:drawLine(int x1,int y1,int x2,int y2)用来绘制从点(x1,y1)到(x2,y2)的线段。当计算出线段上点的坐标不是整数时,向该点的右下方取整。 Ⅲ:drawRet(int x,int y,int width,int height)绘制指定矩形的轮廓。 Ⅳ:drawPloygon(Polygon p)绘制由特定的点指定的多边形。
A.Ⅱ、Ⅲ
B.Ⅱ、Ⅲ、Ⅳ
C.Ⅰ、Ⅱ
D.Ⅰ、Ⅲ、Ⅳ
第16题:
下面是一个Apple(程序,其功能是播放动画。要求根据给出的3幅图片设计1个动画。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
程序运行结果如下:

import java.awt.*;
import java.applet.*;
import java.awt.image.*;
/*
<applet code="ex24_3.class" width=800 height=400 >
</applet>
*/
public class ex24_3 extends Applet implements Runnable {
Image[] images=new Image[4];
Image image;
int IMG nClick=over(this) title=放大Number=3;
int currentImage=0;
Thread thisThread;
public void init(){
for (int x=0;x<IMG nClick=over(this) title=放大Number;x++){
images[x]= getImage(getCodeBase(),"IMG nClick=over(this) title=放大"+x+".gif");
}
image=images[0];
}
public void paint(Graphics g){
g.drawImage(image[0],0,0,null);
}
public void update(Graphics g){
paint(g);
}
public void start(){
thisThread = new Thread(this);
thisThread.start();
}
public void stop(){
thisThread.stop();
thisThread=null;
}
public void run(){
while(true){
currentImage++;
currentImage=IMG nClick=over(this) title=放大Number;
image=images[IMG nClick=over(this) title=放大Number];
repaint();
try{
thisThread.sleep(100);
}
catch (Exception e){}
}
}
}
ex24_3, html
<HTML>
<HEAD>
<TITLE>ex24_3</TITLE>
</HEAD>
<BODY>
<applet code="ex24_3.class" width=800 height=400 >
</applet>
</BODY>
</HTML>
第17题:
此题为判断题(对,错)。
第18题:
设置表格的宽度为600的HTML代码是()
第19题:
对于drawImage(image,x,y,width,height,this)方法解释正确的是()。
第20题:
JAVA中,对于drawImage(image,x,y,width,height,this)方法解释正确的是()。
第21题:
以下定位,脱离文档流的是()。
第22题:
image是要绘制的图像
x,y是表示图像的中心的位置
width是源图像的宽度
this是容器
第23题:
<Image Width=200 Source=Image1.jpg/> <Image Width=200 Height=200 Source=Image1.jpg/> <ImageWidth=200><Image.Source>
<BitmapImage DecodePixelWidth=200DecodePixelHeight=200UriSource=Image1.jpg /> </Image.Source>
</Image><Image Width=200><Image.Source>
<BitmapImage DecodePixelWidth=200 UriSource=Image1.jpg /></Image.Source> </Image>
第24题:
setSize(int width,int height)
setSize(int x,int y,int width,int height)
setSize(Dimension dim)
以上皆不是