TIWApplet(用于 WEB 的 VCL)程序和 RAD Delphi XE
我正在尝试使用 RAD Studio Delphi XE 同时学习和编程。我正在利用 TIWApplet 编写一个迷你(VCL for the web)程序。我有一个小程序,它只是在小程序上显示文件中的图像。 java applet 代码编译成功并创建了一个 .class 文件。然后,我相应地设置了该小程序的 TIWapplet 属性。
我的 VCL Web 程序已编译并且可以运行它。但是,每当我打开浏览器查看小程序时,都会收到一条错误消息,指出“无法加载 appletImage.class 文件”。但我可以通过创建一个 html 文件并用浏览器打开它来查看小程序。
那么,为什么 TIWapplet 打不开我的小程序呢?
我在互联网上上下搜索,甚至浏览了他们的示例和演示。它们根本没有帮助,或者甚至没有任何与(VCL for the Web)程序相关的东西。
这是 Java Applet 代码:
import java.applet.*;
import java.awt.*;
public class appletImage extends Applet{
Image img;
MediaTracker tr;
public void paint(Graphics g) {
tr = new MediaTracker(this);
img = getImage(getCodeBase(), "testing.jpg");
tr.addImage(img,0);
g.drawImage(img, 0, 0, this);
}
}
这是 HTML 代码:
<html>
<head>
<title>Arc Test (1.1)</title>
</head>
<body>
<h1>Arc Test (1.1)</h1>
<hr>
<applet code=appletImage.class width=400 height=400>
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</applet>
</body>
</html>
I am trying to learn and program at the same time using RAD Studio Delphi XE. I am writing a mini (VCL for the web) program by utilizing TIWApplet. I have an applet that simply displays an image from a file on an applet. The java applet code compiled successfully and created a .class file. Then, I accordingly set the TIWapplet properties for the applet.
My VCL for the web program compiles and I am able to run it. However, whenever I open the browser to view the applet, I get an error stating, "Can't load appletImage.class files." But I am able to view the applet by creating a html file and opening it with a browser.
So, why can't TIWapplet open my applet?
I've searched the Internet up and down and even looked through their samples and demos. They are not helpful at all or that they don't even have anything related to (VCL for the Web) program.
Here is Java Applet code:
import java.applet.*;
import java.awt.*;
public class appletImage extends Applet{
Image img;
MediaTracker tr;
public void paint(Graphics g) {
tr = new MediaTracker(this);
img = getImage(getCodeBase(), "testing.jpg");
tr.addImage(img,0);
g.drawImage(img, 0, 0, this);
}
}
Here is the HTML code:
<html>
<head>
<title>Arc Test (1.1)</title>
</head>
<body>
<h1>Arc Test (1.1)</h1>
<hr>
<applet code=appletImage.class width=400 height=400>
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</applet>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过在浏览器中访问类文件 URL?如果您输入其 URL,
浏览器应打开一个对话框并提示下载 Applet 类文件。
如果浏览器显示 404(或未找到其他资源)消息,则 IntraWeb 不会通过 HTTP 提供类文件(或使用不同的位置)。
Have you tried to access the class file URL in the browser? If you enter its URL
the browser should open a dialog and prompt to download the Applet class file.
If the browser shows a 404 (or other resource not found) message, IntraWeb does not serve the class file over HTTP (or uses a different location for it).