Chapter 14 Applets. 2 Knowledge Goals Understand the differing roles of applications and applets Understand how a browser operates Understand the role.

Slides:



Advertisements
Similar presentations
The World Wide Web. 2 The Web is an infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that.
Advertisements

Chapter 16 The World Wide Web Nell Dale John Lewis.
Chapter 16 The World Wide Web.
Slides prepared by Rose Williams, Binghamton University Mouse Events + Chapter 17: Applets.
COMP 14 Introduction to Programming Miguel A. Otaduy June 8, 2004.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 21, 2005.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic.
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.
Slides prepared by Rose Williams, Binghamton University Chapter 18 Applets.
Java Applets. Lecture Objectives Learn about Java applets. Know the differences between Java applets and applications. Designing and using Java applets.
Introduction to HTML 2006 CIS101. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Introduction to HTML 2006 INT197B. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Introduction to HTML 2004 CIS101. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
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.
Applets, HTML and GUI’s Recitation – 04/11/2008 CS 180 Department of Computer Science, Purdue University.
Chapter 16 The World Wide Web. 2 The World Wide Web (Web) is an infrastructure of distributed information combined with software that uses networks as.
CIS101 Introduction to Computing Week 06. Agenda Your questions Excel Exam during second hour Our status after the snow day Introduction to the Internet.
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Chapter 16 The World Wide Web. 2 Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic HTML.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Chapter 16 The World Wide Web. 2 Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic HTML.
Chapter 9: Applets Jim Burns Fall Outline Learn about applets Learn about applets Write an HTML doc to host an applet Write an HTML doc to host.
Web Design Using HTML Codes. WHAT DO I NEED TO BEGIN DESIGNING A HOME PAGE? 1.YOU NEED A FOLDER (also called a DIRECTORY) You should set up a folder or.
Chapter 16 The World Wide Web Chapter Goals ( ) Compare and contrast the Internet and the World Wide Web Describe general Web processing.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
Chapter 13Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 13 l HTML l Applets Applets and HTML.
16-1 The World Wide Web The Web An infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information.
CPS120: Introduction to Computer Science The World Wide Web Nell Dale John Lewis.
Internet Fundamentals Total Advantage MS Excel 97, Hutchinson, Coulthard, 1998 McGraw Introduction to HTML Chapter 7.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
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.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic.
Chapter 16 The World Wide Web. 2 The Web is an infrastructure of distributed information combined with software that uses networks as a vehicle to exchange.
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.
Lesson 36: The calculator – Java Applets. 1. Creating Your First Applet HelloWorldApp is an example of a Java application, a standalone program. Now you.
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
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.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic.
GUI programming Graphical user interface-based programming.
Chapter 13. Applets and HTML HTML Applets Computer Programming with JAVA.
Chapter 13Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 13 l HTML l Applets Applets and HTML.
1 John Magee 9 November 2012 CS120 Lecture 17: The World Wide Web and HTML Web Publishing.
Nell Dale & John Lewis (adaptation by Michael Goldwasser) The World Wide Web.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Lec.10 + (Chapter 8 & 9) GUI Java Applet Jiang (Jen) ZHENG July 6 th, 2005.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
Ali Alshowaish. What is HTML? HTML stands for Hyper Text Markup Language Specifically created to make World Wide Web pages Web authoring software language.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Introducing the World Wide Web Internet- a structure made up of millions of interconnected computers whose users communicate with each other and share.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Applets Yong Choi School of Business CSU, Bakersfield.
Java Programming Applets. Topics Write an HTML document to host an applet Understand simple applets Use Labels with simple AWT applets Write a simple.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
1 GUI programming Graphical user interface-based programming Chapter G1 (pages )
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 Java code is compiled into byte code instead of machine language –Languages like C, C++, Pascal and others are compiled into machine language so.
Creating a Java Application and Applet
Writing Your Own Web Page: Using HTML and FrontPage Chapter 10.
1 2/16/05CS120 The Information Era Chapter 4 Basic Web Page Construction TOPICS: Intro to HTML and Basic Web Page Design.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Applets. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L12: Applets Slide 2 Applets Usually.
Chapter 14 Applets. Applets: Introduction Java programs are divided into two main categories, applets and applications An application is an ordinary Java.
Java Applet What is a Java Applet? How is applet compiled?
Chapter 8 Introduction to HTML and Applets
Ellen Walker Hiram College
Java Applets.
Chapter 16 The World Wide Web.
Presentation transcript:

Chapter 14 Applets

2 Knowledge Goals Understand the differing roles of applications and applets Understand how a browser operates Understand the role of HTML

3 Skill Goals Write an applet to perform a simple task Embed Bytecode within a web page Construct a simple HTML web page that executes an applet

4 What Is an Applet? Applet A mini-application  Distributed along with web pages  Run under a browser at the viewer’s site  Run under an applet viewer  Is distributed in Bytecode form

5 What Is an Applet? Applets differ from applications in several ways  Applets don’t have a main method  Applets are invoked differently  Applets are subject to more security constraints  Applets are not in control of their own destiny  Applets do not have constructors; initializations are done in method init

6 What Is an Applet? Inheritance hierarchy for AWT and Swing

7 How Do We Write Applets? // Applet Factorial computes the factorial of // its input and stores it in a variable of // type int, which is displayed on the // screen. import javax.swing; // JApplet class import java.awt.*; // User interface classes import java.awt.event.*; // Event classes public class FactInt extends Applet implements ActionListener {…}

8 public void actionPerformed(ActionEvent event) { int value; value = Integer.parseInt(inputField.getText()); inputField.setText(""); outLabel.setText(value + " factorial is ” + factorial(value)); } How Do We Write Applets? Method call

9 How Do We Write Applets? private int factorial(int n) // Assumption: n is not negative. { if (n == 0) return 1; else return (n * factorial((n-1))); } Now, we have to set up a button, a label, and a text input field

10 How Do We Write Applets? // Setting up a button, label, and input // field private static JTextField inputField; private static JLabel label; private static JLabel outLabel; private static JButton button; We need to write method init

11 How Do We Write Applets? public void init() { // Instantiate components label = new JLabel("Enter an integer; ” + “press Enter."); outLabel = new JLabel("Answer"); button = new JButton("Enter"); button.addActionListener(this); inputField = new JTextField("Value here"); Note

12 // Add components add(label); add(inputField); add(button); add(outLabel); // Specify a layout manager for the // window object setLayout(new GridLayout(4,1)); } How Do We Write Applets? Why are the add s not applied to an object?

13 How Do You Run an Applet? The Bytecode version of an applet is run on the user’s browser Yes, but how? Some definitions are in order first Computer network A collection of computing devices connected in order to communicate and share resources Can you name some of the devices in a computer network?

14 How Do You Run an Applet? Local area network (LAN) A network that connects a relatively small number of machines in a relatively close geographical area Wide area network (WAN) A network that connects local area networks over a potentially large geographic distance Internet A wide area network that spans the planet

15 How Do You Run an Applet? The Web An infrastructure of information combined and the network software used to access it Uniform Resource Locator (URL) A standard way of specifying the location of a Web page, containing the hostname, "/", and a file What is the relationship between the Internet and the Web?

16 The World Wide Web Why is the expression "visiting a website" confusing?

17 How Do You Run an Applet? Hypertext Markup Language (HTML) The language used to create or build a Web page Markup language A language that uses tags to annotate the information in a document Tags The syntactic element in a markup language that indicates how information should be displayed

18 How Do You Run an Applet? HTML

19 How Do You Run an Applet?

20 How Do You Run an Applet?

21 How Do You Run an Applet? HTML  Tags are enclosed in angle brackets ( )  Words such as HEAD, TITLE, and BODY are called elements and specify the type of the tag  Tags are often used in pairs, with a start tag such as and a corresponding end tag with a / before the element name, such as

22 How Do You Run an Applet? The browser determines how the page should be displayed based on the tags The browser  Ignores the way we format the HTML document using carriage returns, extra spaces, and blank lines  Takes into account the width and height of the browser window  Reformats the contents to fit your browser window

23 How Do You Run an Applet? Tags … … Meaning Enclose document Enclose heading Enclose title Enclose body of document Enclose paragraph Insert horizontal rule Enclosed should be boldface Enclosed should be in italics Preformatted; display text as-is

24 How Do You Run an Applet? Note FactInt.class is the file with the Bytecode version of the Applet FactInt

25 Yes, But How Do You Run an Applet? If you are in an integrated environment, your Java system will run the applet in the viewer To run in a browser,  compile the applet  name the Bytecode file with a.class extension  create the web page with the appropriate  put the.class file in the same directory as the web page  access the web page

26 How Do You Run an Applet? Go to this web page and follow the directions Be sure FactInt.class is with this page

27 How Do You Run an Applet?

28 How Do You Run an Applet?