Java is a general-purpose, concurrent, class-based, object-oriented language. Applets are programs that are embedded in other applications, typically in a web page displayed in a web browser. Java Applets can be used to create animations in HTML web pages.
Java is a general-purpose, concurrent, class-based, object-oriented language. Applets are programs that are embedded in other applications, typically in a web page displayed in a web browser. Java Applets can be used to create animations in HTML web pages.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online from Scribd
Java is a general-purpose, concurrent, class-based, object-oriented language. Applets are programs that are embedded in other applications, typically in a web page displayed in a web browser. Java Applets can be used to create animations in HTML web pages.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online from Scribd
originally developed by James Gosling at sun microsystems.
java is a general-purpose, concurrent, class-based,
object-oriented language. Java is currently one of the most popular programming languages in use, and is widely used in web applications. Why java ?? Five reasons for java :-
(1) It is simple, object oriented, and familiar.
(2) It is robust and secure. (3) It is architecture neutral and portable. (4) It executes with high performance. (5) It is interpreted, threaded, and dynamic. Syntax :-
Java was built almost exclusively as an object
oriented language. All code is written inside a class and everything is an object, with the exception of the intrinsic data types (ordinal and real numbers, boolean values, and characters), which are not classes for performance reasons.
The syntax of Java is simple and resembles that of
C++. JAVA APPLETS What are java applets ?
Java applets are programs that are embedded in
other applications, typically in a Web page displayed in a Web browsers
An applet is placed in an HTML document using
the <applet> HTML element.The applet tag has three attributes set: code=“name.class" specifies the name of theJApplet class and width=“n" height=“n" sets the pixel width and height of the applet. an example of an applet
Explanation:-
In the above program we import java.swing.Japplet
and java.awt.Graphics these are the two classes which enable applets to use swing components. Then we extend our class file as an applet by using the command public class hello extends JApplet Then we call the paint component and use the g.drawString() function which intakes the content and the height and width and draws the content which we want to. Then we compile the .java file to .class file and bind it to a HTML file to get our applet running on a webpage. Now as we know what Java Applets are let us see how we can create animations in HTML web pages with the help of a JAVA Applet. Animated rings :-
In this small animation which we are going to
create we will make a screen full of colorful rings expanding and contracting alternatively , a screen shot can be seen here:- In the source code we are first declaring the necessary variables in their respective data types
Then create the necessary function to create and
color the circles.
Then we create the functions to set the circles into
motion by alternatively showing them on screen.
Rest of the program constitutes Java syntax. A
greater knowledge of java syntax is needed to understand that. As we are looking at the various uses of java let us ignore the syntax for time being and move on to see what we can create with java applets. Binding the Code to the Web page :-
Java Applets may differ from one another but
binding them to a HTML page is a same process with every applet
This is done by adding <applet> tag in your HTML
script.
After compiling our program we will get a bytecode
file or the .class file then we bind it as mentioned above and get our applet working on the web page. The applet :-
This is how our applet will look after its done.