Wednesday, November 27, 2013

3 Ways to Make a Java Applet

Applets came with a great promise of embedding software into web pages. It is very powerful if used properly. They are used by some banks for client login, which speaks greatly of its security features.
STEPS
METHOD 1 OF 3: SETTING UP THE ENVIRONMENT



1
DOWNLOAD AND INSTALL JDK[
1
]. Check the Sources and Citations for the download link from Sun's website.
Download and install some Java IDE, to make things easier. Netbeans or Eclipse are good Open Source tools.



2
MAKE A FOLDER FOR YOUR SOURCE CODES AND PROJECTS.
METHOD 2 OF 3: TESTING THE SAMPLE APPLET



1
OPEN NOTEPAD AND COPY AND PASTE THE CODE IN THE CODE SECTION.



2
CLICK FILE, AND THEN CLICK SAVE AS, AND SAVE IT IN YOUR JAVA FOLDER BUT NAME THE CODE "TEST.java" (without quotation marks)



3
EXIT THE WINDOW AND CLICK START, RUN, THEN TYPE IN CMD IN THE BOX AND HIT OK.



4
TYPE CD C:jdk6bin and hit enter



5
TYPE JAVAC THEN C:javatest.java and hit enter.



6
NOW COPY AND PASTE THE LAUNCHER INTO NOTEPAD AND CLICK FILE, AND THEN CLICK SAVE AS, AND SAVE IT IN YOUR JAVA FOLDER BUT NAME THE LAUNCHER. "test.htm" (without quotation marks).



7
NOW GO TO THE JAVA FOLDER YOU MADE AND LAUNCH THE TEST.htm file.
METHOD 3 OF 3: EMBEDDING A JAVA PROGRAM INTO AN APPLET
NOTE: You need to know how to program Java in order to make your own applet.



1
OPEN YOUR MAYANK OF CHOICE OR A SIMPLE TEXT OR (LIKE NOTEPAD IN WINDOWS).



2
CODE A JAVA PROGRAM TO DO SOMETHING. Make it a subclass of JPanel[
2
], so you can put it into a top level swing container like a JAPPLET[3] or a JFRAME[4]



3
CREATE A BASIC JAPPLET TO LAUNCH YOUR JPANEL PROGRAM.
Override the
start() method, get a reference to the contentPane, add your JPanel to it and repack the Applet.
You might need to fine-tune the component allocation on the JPanel, to better fit the applet window.



4
USE THE SAME PROCEDURE AS FOR COMPILING AND LOADING THE SAMPLE APPLET TO PACK YOUR PROGRAM AND RUN IT ON THE BASIC LAUNCHER.
TIPS
When installing JDK, install all the features. You will need them.
Applets running over the internet have strict security policy than Java software running Locally. You will have to digitally sign[5] your applet to give it more freedom (but not all the rights of a local software) like making file operations.
THINGS YOU\'LL NEED
Java programming skills
JDK.(Java Devolpment Kit and Java Runtime Environment) You can download it through the link below
Computer with Windows, Linux, or Mac
An internet browser

No comments:

Post a Comment