12-2 Chapter Topics Chapter 14 discusses the following main topics: Introduction to Applets A Brief...

Preview:

Citation preview

Chapter 14Applets and More

12-2

Chapter TopicsChapter 14 discusses the following main topics:

Introduction to AppletsA Brief Introduction to HTMLCreating Applets with SwingUsing AWT for PortabilityDrawing ShapesHandling Mouse and Key EventsTimer ObjectsPlaying Audio

Introduction to Applets

Introduction to Applets

AppleApplet????

An applet is a Java program that is associated with a Web page and is executed in a Web browser as part

of that Web page

Example: file:///D:/DATA/brasko/users/paulo/Pitt%20University/CS-0401/slides%20from%20Editor/Chapter%2014/TempConverter/TempConverter.html

Introduction to AppletsTwo types of Java programs:

Applications A stand-alone program that runs on your computer

Applets Programs that are part of a Web site that is executed

inside the browser window

Introduction to Applets

AppletWeb Page

Applet

Web Page

Applets and Web Pages: Good Friends

We need to learn a little bit about HTML (web pages) in order to be able to understand the relationship between Applets and

Web Pages

A Brief Introductionto HTML

A Good Introduction / hands-on http://www.w3schools.com/html/html_intro.as

p

Adding an Applet into an HTML page

Adding an Applet into an HTML page<!DOCTYPE html><html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p>

<applet width="300" height="300" archive="MyApplet.jar" code="NewJApplet.class"></applet>

</body></html>

Creating an Applet in NetBeans

Creating an Applet in NetBeans

Creating an Applet in NetBeans

Creating an Applet in NetBeans

Creating an Applet in NetBeans

Putting all together:HTML + Applet

Copy the jar and class files

Update Your Web Page

Run the web page fileIn the Windows Explorer, double click on the

html file

Voilá!!!!

Recommended