gpt4 book ai didi

java小程序(绘制快乐或笑脸)

转载 作者:行者123 更新时间:2023-12-02 09:00:21 24 4
gpt4 key购买 nike

我打算使用java画一张笑脸,这是我到目前为止的代码:

import javax.swing.JApplet;
import java.awt.Graphics;
public class HappyFace extends Japplet
{
public void paint(Graphics canvas)
{
super.paint(canvas);
canvas.drawOval(100, 50, 200, 200);
canvas.fillOval(155, 100, 10, 20);
canvas.fillOval(230, 100, 10, 20);
canvas.drawArc(150, 160, 100, 50, 180, 180);
}
}

我收到以下错误:

HappyFace.java:3: error: cannot find symbol
public class HappyFace extends japplet
^
symbol: class japplet
HappyFace.java:7: error: cannot find symbol
super.paint(canvas);
^
symbol: variable super
location: class HappyFace
2 errors

最佳答案

因为没有名为 Japplet 的父类(super class)可供扩展。正如 import 语句所示,它必须是 JApplet。您需要按如下方式进行类声明:public class HappyFace extends JApplet

关于java小程序(绘制快乐或笑脸),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60217691/

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