gpt4 book ai didi

Java Applet 不显示在 HTML 页面上

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

加载 HTML 页面时,我的 Java 小程序(称为 NameInLights.class)不显示。 .class 文件肯定存在,并且 HTML 的其他部分显示在页面上的正确位置。我的浏览器中启用了 Java,并且小程序在 AppletViewer 中运行良好。

这是我的java代码:

import java.util.Random;
import java.awt.*;
import java.applet.*;
public class NameInLights extends Applet {

private static final long serialVersionUID = 1L;
Random r = new Random();
String name = "Imulsion";//must keep my real name secret! :)
public void init(){
setSize(500,500);
}
public void paint(Graphics g){
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.setFont(new Font("Comic sans ms",Font.BOLD,55));
g.drawString(name,125,250);
for(int loop=0;loop<500;loop++)
{
int red = r.nextInt(255);
int green = r.nextInt(255);
int blue = r.nextInt(255);
int x = r.nextInt(500);
int y = r.nextInt(500);
g.setColor(new Color(red,green,blue));
g.setFont(new Font("Times New Roman",Font.BOLD,24));
g.drawString("*",x,y);
}
}
}

这是我的 HTML:

<html>
<body>
<p>
Here comes an awesome applet!
</p>
<br />
<br />
<applet code="NameInLights.class" width = 500 height = 500>
</applet>
<button type = "button" onclick = "window.location.reload()">
Change applet colours
</button>
<body>
<html>

为什么不显示?

最佳答案

好的,Google Chrome 正式不支持已弃用的标签 applet。使用标签 object 代替。

关于Java Applet 不显示在 HTML 页面上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11710694/

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