Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between JApplet and Applet, and which should I use?

Tags:

java

applet

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?

like image 308
Bhaxy Avatar asked Jan 25 '12 19:01

Bhaxy


People also ask

Which is better applet or application?

Applications can execute the programs from the local system. Applets cannot execute programs from the local machine. An application program is needed to perform some tasks directly for the user. An applet program is needed to perform small tasks or part of them.

Which is better swing or applet?

We cannot compare APPLET with SWING. - running it from a Web browser, for it we need to create an HTML file so it can be visualized from Web browser, We can compare SWING with AWT. We could extend Applet from AWT package too, but SWING (JAPPLET) provides a more modern set of graphical user interface (GUI) components.

Do people still use Java applet?

No, there isn't. Java Applets are dead and there is no viable way to run them for the vast majority of users on the public Internet. If you are a software developer, you should abandon applets and start learning a modern full-stack framework. There are many to choose from.

Why applet is not used now?

While previous Java versions have marked Java applets as deprecated, the APIs were left in place to avoid compilation or runtime issues with applications that leveraged the APIs in some way even without not using the applet functionality.


2 Answers

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.

like image 56
Tim Cooper Avatar answered Oct 19 '22 23:10

Tim Cooper


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

like image 39
fenerlitk Avatar answered Oct 19 '22 23:10

fenerlitk