JApplet 和 Applet 之间有什么区别,我应该使用哪一个?
在我的书(我的计算机科学课程)中,他们有源代码片段。我们正在谈论图形编程和小程序。我注意到在某些情况下他扩展了 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
来自
JApplet
的文档:如果您希望在 applet 中使用 Swing 组件,
JApplet
会给出你那个功能。 Swing 已经取代了原来的 AWT,因此使用JApplet
代替Applet
仍然是一个好主意,只是为了跟上当前的库的步伐。From the documentation for
JApplet
: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 useJApplet
in lieu ofApplet
, simply for keeping up with the current libraries.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.
使用
JApplet
。 Swing 比较好,很少有人记得如何使用 AWT 组件。可能不会。许多示例都是这样编写的,以便于编译和运行。代码应该根据最佳设计分为单独的类,并且只有最琐碎的代码才会在单个类中表达。
Use
JApplet
. Swing is better, and few people remember how to use AWT components.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.
小程序-> AWT
JApplet -> Swing + 对辅助技术的支持 +
我建议使用 JApplet
Applet -> AWT
JApplet -> Swing + support for assistive technologies +
I suggest using JApplet
API 规范是这样说的
小程序:
http://docs.oracle.com/javase/6 /docs/api/java/applet/Applet.html
JApplet(扩展Applet):
http://docs.oracle.com/javase/6 /docs/api/javax/swing/JApplet.html
Here's what the API specification says
Applet:
http://docs.oracle.com/javase/6/docs/api/java/applet/Applet.html
JApplet (extends Applet) :
http://docs.oracle.com/javase/6/docs/api/javax/swing/JApplet.html