What is the difference between applets and SWING?
What is the difference 开发者_如何学编程between applets and 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.
Applets will be downloaded at the client web browser and executed locally where as swing has a set of APIs for developing GUI components and can act as stand alone applications.
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.
Swing is light weight Component.
Applet is heavy weight Component.Swing have look and feel according to user view you can change look and feel using UIManager.
Applet Does not provide this facility.Swing uses for stand lone Applications, Swing have main method to execute the program.
Applet need HTML code for Run the Applet.Swing uses MVC Model view Controller.
Applet not.Swing have its own Layout like most popular Box Layout. Applet uses AWT Layouts like flowlayout.
Swing have some Thread rules.
Applet doesn't have any rule.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.
精彩评论