Install Net Beans IDE ,
that you can download from the Sun website
From Menu Select
File>>New Project (Ctl+Shift+N), Select Java Class Library
Next Type MyApplet as Project Name
and c:\MyJava as the directory (you will use this later also)
Click
Finish
Now in Projects Tab Your Project Root Tree is listed and created Under 'MyApplet'
Now its time to Add an Applet to your Project
Right Click to get Context Menu then select New>>Applet..
A dialog will appear , Note that you have a Recommended Name NewApplet, Leave As is and Click Finish
Now you will See Your 'NewApplet' listed in the Navigation tree and your Code 'NewApplet.java' in the right pane
To start with:
just above the main Function use the import statement to include the awt libraries
Awt is the Abstract Window Toolkit Class Libraries that we are using now to access Color and Graphics features
Just under the init( ) procedure add the paint procedure as described below
A little explanation of the code, We're playing with the color values,
Each color is composed of three components
r--red (0-255)
g--green (0-255)
b--blue (0-255)
In the above code what we are simply doing is looping the paint code and change the drawn
color to all possible combination in an incremental fashion
Our drawing code is making a new Color, assigning it to graphics,
And then printing a "Hello World" statement at position x=10,y=10
Now to test your Applet Select
NewApplet.java>>RtClick>>Run File
If eve is Ok, Your First Applet is Ready and should run in Flashing Colors in a new
Window
Use Build>>Stop Build/Run to Stop it
Now I'll guide you to place this applet on your webpage or blog
In your Explorer Open the Location c:\MyJava (You selected this location at initial steps)
Further Move into the build folder
Here netbeans have generated an HTML File you can open it to preview in your browser
Here is how it looked in my firefox browser
To place it on your webpage , you need to place it online, if you own a website you probably
have ftp access to your website
Upload the classes folder (including MyApplet.class) to your location where your webpages
are placed
Get the URL of your applet classes folder
If your URL is
http://sites.google.com/site/t6tfiles/Home/NewApplet.class
You can use this
HTML code to embed in your blog
<applet codebase="http://sites.google.com/site/t6tfiles/Home" code="NewApplet.class" width=300 height=100></applet>
Here's How it will Function:-
Here is the source code of this example
http://sites.google.com/site/t6tfiles/Home/NewApplet.java