File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes applet and application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "applet and application" Watch "applet and application" New topic
Author

applet and application

salvador rcn
Ranch Hand

Joined: Feb 18, 2004
Posts: 51
is it possible applet and application both can retain in a single code ?
in fact when i need applet i will use applet and when i need application i will use application . can they stay both in a sigle code ?

how do i invoke them if both of them exists ?

thankig you
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The only real difference between an Applet and an application is the environment they run in. An Applet runs in a "sandboxed" environment in a browser, an application runs in a JVM with no such restrictions. If your Applet and application have common functionality it makes sens to create this in a set of shared classes so they can be invoked from either.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
salvador rcn
Ranch Hand

Joined: Feb 18, 2004
Posts: 51
>it makes sens to create this in a set of shared classes so they can be invoked from either.

set of shared classes ?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Typically, when I create GUI applications, I create one class that extends JFrame and another that extends JPanel. The frame class has minimal logic; it adds the panel to its content pane and creates a menu (if I want one). The JPanel class on the other hand has most of the logic to create the GUI controls (buttons, text fields, labels, etc.). This allows me to easily create a third class that extends JApplet and just adds the already-written panel with most of the GUI logic set up. I only have to provide an alternative to the menu that was in the JFrame class. In a program of any major complexity, there are also other classes that do the actual work of the program. It's usually a good idea to separate the "business logic" from the "GUI logic" as much as possible.

To clarify my written explanation above, here's a quick example of some code:

HTH

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: applet and application