填空题
下列JApplet使用重写paintComponet()方法来绘制图像,请填写正确的代码在横线处。
import java.awt.*;
import javax.swing.*;
public class Test extends JApplet
staic String fileName = "img().gif";
public void init()
Container cp = getContentPane();
cp.setLayout(new GridLayout(1,1));
Image i = getImage(getCodeBase(),fileName);
MyImagePanel ip=new MyInmagePanel(i);
cp.add(ip);
class MyImagePanel extends JPanel
Image i;
public MyImagePanel(Image img)
this.i = img;
public void paintComponent(Graphics gg)
【15】
;
gg.drawImage(i,20,20,this);
【参考答案】
super.paintComponent(gg)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
现在有Java Applet小程序的源程序文件MyApplet.java,编译后生成的字节码文件为MyApplet.class,对应的HTML文件为MyApplet.html。查看该小程序的运行结果两种方式:运行命令 【14】 ;直接用浏览器打开MyApplet.html文件。
点击查看答案&解析
填空题
编写同时具有Applet与Application特征的程序,具体的方法是:作为Application要定义main()方法,并且把main()方法所在的类定义为一个 【13】 类,为使该程序成为一个Applet,main()方法所在的这个类必须继承Applet类或JApplet类。
点击查看答案&解析
相关试题
以下程序段的输出结果是( )。 int x=...
有下列程序段 public class fun public...
有如下代码段 public class OperatorAnd...
如下的代码段中,如果方法unsafe()正常运...
下列程序的输出结果为( )。 public cl...