JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN 0136091113 © 2009 Pearson Education, Inc., Upper.

Slides:



Advertisements
Similar presentations
Learn about Java applets. Know the differences between Java applets and applications. Designing and using Java applets Running Java applets. Security.
Advertisements

Dept. of Computer Science - SSBN Java Applets Vishnuvardhan.M.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Slides prepared by Rose Williams, Binghamton University Mouse Events + Chapter 17: Applets.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
Slides prepared by Rose Williams, Binghamton University Chapter 18 Applets.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
Chapter 12Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Announcements/Reminders l Happy Tax Day! l Project 8 due on Thursday.
Java Applets. Lecture Objectives Learn about Java applets. Know the differences between Java applets and applications. Designing and using Java applets.
Chapter 131 Applets and HTML Chapter Reminders Project 8 due Dec 10:30 pm Project 6 regrades due by midnight tonight –Submit all files (including.
HTML Companion. Lecture Objectives Learn about HTML. Know basic HTML tags.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 Object-Oriented Languages.
Chapter 20 Applets Slides prepared by Rose Williams, Binghamton University Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Applets, HTML and GUI’s Recitation – 04/11/2008 CS 180 Department of Computer Science, Purdue University.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Chapter 13Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 13 l HTML l Applets Applets and HTML.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
JAPPLET.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Chapter 8 Introduction to HTML and Applets Fundamentals of Java.
1 Week 1 l HTML l Applets Applets and HTML. 2 Overview l Applets: Java programs designed to run from a document on the Internet l HTML: Hypertext Markup.
Chapter 13. Applets and HTML HTML Applets Computer Programming with JAVA.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Chapter 13Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 13 l HTML l Applets Applets and HTML.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Creating Applets. What is an applet? What is an applet? A Java program that runs in a web browser. A Java program that runs in a web browser. An applet.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Chapter 131 Applets and HTML Chapter Objectives learn how to write applets learn to write a simple HTML document learn how to embed an applet in.
Applets, Images, and Audio Chapter 14 CSCI CSCI 1302 – Applets, Images, and Audio2 Outline Introduction The Applet Class –The init Method –The start.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Invitation to Computer Science 6 th Edition Chapter 10 The Tower of Babel.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Word 2003 Working Together 1 Word 2003 and Your.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Will not cover Section 3.7 Thinking About Objects: Identifying.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 17 : Applets King Fahd University of Petroleum & Minerals College of Computer Science.
Chapter 14 Applets. Applets: Introduction Java programs are divided into two main categories, applets and applications An application is an ordinary Java.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Java Applets.
Java Applets.
Chapter 13 Applets and HTML HTML Applets.
Presentation transcript:

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Walter Savitch Frank M. Carrano Walter Savitch Frank M. Carrano Applets and HTML Chapter 14

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Objectives Write applets Write simple HTML documents Embed an applet in an HTML document

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applet Basics "Applet" stands for small application Applets are similar to a Swing GUI An applet is an object derived from class JApplet  Must use import javax.swing.JApplet; A JApplet object is a container  Possible to add components to the object

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applet Basics Figure 14.1 placing applets in the class hierarchy Object

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applet Basics Figure 14.1 placing applets in the class hierarchy

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applet Basics Applets do not use constructors  Initialization code placed in method init() Normal way to run an applet is as part of a web page Also possible to run the applet with an applet viewer

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved A Trivial Applet View sample applet, listing 14.1 class HelloAppletsample applet Sample screen output

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved An Adder Applet Consider an applet which performs addition – same as in chapter 13 View code, listing 14.2 class AdderAppletcode Sample screen output

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Adding Icons to an Applet An icon is an ImageIcon object that represents a picture View sample applet, listing 14.3 class DukeAppletsample applet Sample screen output

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Introduction to HTML Stands for HyperText Markup Language It is a language for writing web pages  It uses tags to mark text Typical command format Note: HTML is not case sensitive An HTML file is an ordinary text file

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Outline of Simple HTML Document Listing 14.4a

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Outline of Simple HTML Document Listing 14.4b

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Example of an HTML Document Listing 14.5a

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Example of an HTML Document Listing 14.5b

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Browser Output

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Inserting Hyperlinks Provides an active element of the web page Links to other web locations Syntax:

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Displaying a Picture HTML document can contain both text and pictures Syntax options:

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applets in HTML Applets may be imbedded in HTML documents, listing 14.6a

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applets in HTML Applets may be imbedded in HTML documents – listing 14.6b

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Browser Output Listing 14.6c

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Applets and Security On a remote computer, applets cannot  Run programs  Access files Be warned that other programs besides applets can run via the browser  Protection software is advised

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved The Older Applet Class Use import Java.applet.Applet; Does without the Swing classes Has no content pane  Use.add() method with the applet itself

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Summary Applets are Java programs designed to be placed in and run from a Web document. Applets are similar to Swing GUIs derived from the class JFrame. An applet is normally a derived class of the class JApplet.

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Summary An applet normally has no main method and no constructors.  Method init serves the same purpose as a constructor for an applet An applet’s init method does not include any invocations of  addWindowListener,  setTitle  setSize.

JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Summary HTML documents are designed to be read and displayed by a web browser HTML stands for HyperText Markup Language Applets can be imbedded in, run from an HTML document