简体   繁体   中英

What is the difference between applets and SWING?

小程序和SWING有什么区别?

See Applets

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM).

See Swing (Java)

Swing is a widget toolkit for Java. It is part of Sun Microsystems' Java Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs.

Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit. Swing provides a native look and feel that emulates the look and feel of several platforms, and also supports a pluggable look and feel that allows applications to have a look and feel unrelated to the underlying platform.

An applet is a small program that often runs in a web browser Java plugin.

A swing is a piece of playground equipment usually consisting of a seat suspended by two chains or ropes. It's quite fun. :)

In all seriousness, though, Swing is a Java GUI library. It provides components such as buttons and text fields. You can use Swing components in an applet.

小程序将在客户端Web浏览器下载并在本地执行,其中swing具有一组用于开发GUI组件的API,并且可以作为独立的应用程序。

Short answer: Applets are intended to be small bits of functionality run in a web browser and downloaded on-demand. Swing is a collection of user interface components, like text boxes and windows, that are meant to be assembled by a developer for use on the desktop.

Long answer: See adamantium's answer.

I think the confusion is with all the terminology you initially encounter when building applets.

Applet is the overall name for a programme that runs in a Java sandbox in a web browser. It is also a specific Java class ( java.applet.Applet ). The entry class of this programme must extend Applet.

Applets originally (upto Java version 1.1) could only use AWT user interface components.

Since Java version 1.3 Swing components may be used instead. In this case your entry class must extend JApplet .

Swing :- Swing is light weight component . Swing have it's own layout like most popular box layout. Swing have some thread rules.

Applet :-

Applet is heavy weight component. Applet uses AWT layout like flowlayout. Applet doesn't have any rules.

  1. Swing is light weight Component.
    Applet is heavy weight Component.

  2. Swing have look and feel according to user view you can change look and feel using UIManager.
    Applet Does not provide this facility.

  3. Swing uses for stand lone Applications, Swing have main method to execute the program.
    Applet need HTML code for Run the Applet.

  4. Swing uses MVC Model view Controller.
    Applet not.

  5. Swing have its own Layout like most popular Box Layout. Applet uses AWT Layouts like flowlayout.

  6. Swing have some Thread rules.
    Applet doesn't have any rule.

  7. Swing:-To execute Swing no need any browser By which we can create stand alone application But Here we have to add container and maintain all action control with in frame container.


Applet : to execute Applet program we should need any browser like AppletViewer, a web browser. Because Applet is using browser container to run and all action control with in browser container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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