JApplet 和 Applet 之间有什么区别,我应该使用哪一个?

发布于 2024-12-29 08:42:21 字数 318 浏览 2 评论 0原文

在我的书(我的计算机科学课程)中,他们有源代码片段。我们正在谈论图形编程和小程序。我注意到在某些情况下他扩展了 JApplet,而在其他情况下他使用 Applet。

我想知道有什么区别,以及它们将如何影响代码?

最近,我的任务是创建一个图形刽子手游戏,其中用户尝试猜测计算机的单词。我应该使用 JApplet 还是 Applet(我们主要使用 JApplet,这就是我倾向于使用 JApplet 的原因,但我可以选择任何一种方式)。

此外,我想知道小程序中的基本过程应该是什么,有些人确实将所有代码都放在扩展 JApplet 或 JFrame 的单个文件中。我应该这样做吗?

In my book (for my computer science course) they have source code snippets. We're talking about graphics programming and applets. I've noticed that in some cases he extends JApplet, while in others he uses Applet.

I was wondering what the differences were, and how they would affect the code?

Recently, I've been tasked with creating a graphical hangman game, wherein the user tries to guess the computer's word. Should I use a JApplet or Applet (we've mostly used JApplet, which is why I'm leaning towards that, but I could go either way).

Furthermore, I was wondering what the basic process should be in an applet, some people do have all their code in a single file that extends JApplet or just JFrame. Should I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

从﹋此江山别 2025-01-05 08:42:21

来自JApplet文档

java.applet.Applet 的扩展版本,添加了对 JFC/Swing 组件架构的支持

如果您希望在 applet 中使用 Swing 组件,JApplet 会给出你那个功能。 Swing 已经取代了原来的 AWT,因此使用 JApplet 代替 Applet 仍然是一个好主意,只是为了跟上当前的库的步伐。

From the documentation for JApplet:

An extended version of java.applet.Applet that adds support for the JFC/Swing component architecture

If you're looking to use Swing components inside of your applet, JApplet would give you that functionality. Swing has superseded the original AWT, so it would still be a good idea to use JApplet in lieu of Applet, simply for keeping up with the current libraries.

猫瑾少女 2025-01-05 08:42:21

Applet 是 AWT,而 JApplet 是 Swing,JApplet 是 Applet 的扩展版本,因此它更新。

Applet is AWT whereas JApplet is Swing, JApplet is the extended version of Applet, therefore it is more recent.

与风相奔跑 2025-01-05 08:42:21

使用JApplet。 Swing 比较好,很少有人记得如何使用 AWT 组件。

此外,我想知道小程序中的基本流程应该是什么,有些人确实将所有代码都放在扩展 JApplet 或 JFrame 的单个文件中。我应该这样做吗?

可能不会。许多示例都是这样编写的,以便于编译和运行。代码应该根据最佳设计分为单独的类,并且只有最琐碎的代码才会在单个类中表达。

Use JApplet. Swing is better, and few people remember how to use AWT components.

Furthermore, I was wondering what the basic process should be in an applet, some people do have all their code in a single file that extends JApplet or just JFrame. Should I do that?

Probably not. Many examples are written that way in order to make them easy to compile and run. Code should be divided into separate classes according to the best design, and only the most trivial of code would be expressed in a single class.

只等公子 2025-01-05 08:42:21

小程序-> AWT

JApplet -> Swing + 对辅助技术的支持 +

我建议使用 JApplet

Applet -> AWT

JApplet -> Swing + support for assistive technologies +

I suggest using JApplet

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文