gpt4 book ai didi

java - 在Applet中显示图像

转载 作者:行者123 更新时间:2023-12-02 07:44:15 25 4
gpt4 key购买 nike

package org.kodejava.example.applet;

import java.applet.Applet;
import java.awt.*;

public class AppletGetImage extends Applet {
private Image logo;

@Override
public void init() {

logo = getImage(getDocumentBase(), "/images/logo.png");
}

@Override
public void paint(Graphics g) {
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
g.drawImage(logo, 10, 10, this);
}
}

问题:

  1. compalsary包在所有java程序中声明吗?
  2. 私有(private)图像 Logo ;该变量可以在小程序类中用于什么目的?
  3. public void init()该方法可以在 applet 类中用于什么目的?

最佳答案

compalsary package declare in all java program?

没有。请参阅此处了解更多信息:Java Package

private Image logo; for which purpose this variable can be use in applet class?

请参阅此处:Declaring Member Variables in Java

public void init() for which purpose this method can be use in applet class?

请参阅此处:Life Cycle of an AppletApplet init() method

关于java - 在Applet中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11113594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com