简体   繁体   English

如何在intelliJ中使用小程序?

[英]How to use applets in intelliJ?

I'm a java beginner and I wanna know how to use applets.我是一名 Java 初学者,我想知道如何使用小程序。 I've got this little test-program for the paint-applet:我有这个用于 paint-applet 的小测试程序:

import java.awt.*;
import java.applet.*;
public class Main extends Applet {
    public void init() {
    }
    public void paint(Graphics g) {
        setBackground(Color.blue);
        g.setColor(Color.yellow);
        g.drawRect(20, 20, 100, 50);
        g.fillRect(20, 80, 100, 50);
    }
}

But in the IDE, "Applet" in the 3rd line has a stripe through it.但是在 IDE 中,第三行的“Applet”有一个条纹穿过它。 And if I try to run the code, I get this error:如果我尝试运行代码,则会出现此错误:

Error: Could not find or load main class sun.applet.AppletViewer
Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer

I'm using IntelliJ as IDE and use jdk14我使用 IntelliJ 作为 IDE 并使用 jdk14

Can someone help?有人可以帮忙吗?

Applets are deprecated since java 9. You should be using java 8 (jdk 14 does not work)自 java 9 以来,Applet 已被弃用。您应该使用 java 8(jdk 14 不起作用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM