简体   繁体   English

Java Swing和Java Applets有什么区别

[英]What's the difference between Java Swing & Java Applets

I've got a question today and would like to know which would be better to use in Java development. 我今天有一个问题,想知道在Java开发中使用哪种更好。 Which would be better to use: Java Swing OR Java Applet . 使用哪种更好: Java Swing或Java Applet I am new to Java development and have been confused between the two. 我是Java开发的新手,两者之间一直很困惑。

  • If you were creating a game which would be better to use. 如果您要创建一个更好用的游戏。
  • Which is better to understand and uses less lines ect. 哪个更好理解,使用更少的线条等。
  • Which is light weight? 哪一个重量轻?

Any questions would be awesome! 如有任何疑问将是真棒!

Java Swing OR Java Applet Java Swing或Java Applet

There is some confusion here. 这里有些混乱。

AWT has Frame for desktop applications/ Applet for applets. AWT具有用于桌面应用Applet Frame /用于小Applet的小程序。 Swing has JFrame for desktop applications/ JApplet for applets. Swing的JFrame用于桌面应用程序, JApplet用于小程序。

Other matters: 其他事项:

  1. AWT/Swing. AWT /摇摆。 Why AWT rather than Swing? 为什么选择AWT而不是Swing? See this answer on Swing extras over AWT for many good reasons to abandon using AWT components. 有很多充分的理由放弃使用AWT组件,因此可以在AWT上的Swing Extras上看到此答案。 If you need to support older AWT based APIs, see Mixing Heavyweight and Lightweight Components . 如果您需要支持较旧的基于AWT的API,请参阅混合重量级和轻量级组件

  2. Applet vs. application. Applet与应用程序。 Why code an applet? 为什么要编写小程序? If it is due to spec. 如果是由于规格。 by teacher, please refer them to Why CS teachers should stop teaching Java applets . 请向老师介绍为什么CS老师应该停止教Java小程序

Many of the components in javax.swing.* have made other still accessible JDK components obsolete, such as AWT. javax.swing.*许多组件已经淘汰了其他仍可访问的JDK组件,例如AWT。 Swing is actually built on top of AWT, and is a large improvement in performance, features, and usage over AWT. Swing实际上是建立在AWT之上的,与AWT相比,Swing在性能,功能和用法上都有很大的改进。

This tutorial on custom graphics with Swing may help: http://www.ntu.edu.sg/home/ehchua/programming/java/J4b_CustomGraphics.html 关于使用Swing的自定义图形的本教程可能会有所帮助: http : //www.ntu.edu.sg/home/ehchua/programming/java/J4b_CustomGraphics.html

As for Java Applets , these are unrelated to Swing in terms of normal application development. 至于Java Applet ,就正常的应用程序开发而言,这些与Swing无关。 Java Applets are small applications that can run in a web browser. Java Applet是可以在Web浏览器中运行的小型应用程序。

Swing is a set of platform independent UI tools (JButton, JScrollBar, etc.). Swing是一组独立于平台的UI工具(JButton,JScrollBar等)。 It guarantees that your user interface design will look the same on different platforms. 它保证您的用户界面设计在不同平台上看起来相同。 An applet is an app that runs inside a browser or other hosted environment. 小程序是在浏览器或其他托管环境中运行的应用程序。 An applet can use Swing UI, but doesn't need to. 小程序可以使用Swing UI,但不需要。

Personally, I wouldn't develop a game in either if it's graphics intensive. 就个人而言,如果图形密集型,我也不会开发游戏。 If you want lightweight, I would suggest using JavaScript in Chrome's V8. 如果您想轻量级,我建议在Chrome的V8中使用JavaScript。 Check out Chrome's developer showcase. 查看Chrome的开发人员展示。 They're doing amazing things with Javascript these days. 这些天来,他们在用Javascript做惊人的事情。

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

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