Java Applet & JavaScript SNU OOPSLA Lab. October 2005.

Slides:



Advertisements
Similar presentations
Java Applets:. How Applets differ from application?: They do not use main method but init(), start() and paint() methods of the applet class They can.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
The Web Warrior Guide to Web Design Technologies
Java Applets. An applet is a Panel that allows interaction with a Java program. A applet is typically embedded in a Web page and can be run from a browser.
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999.
18-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Applets, Graphical User Interfaces, and Threads / Chapter 9 1 Applets, Graphical User Interfaces, and Threads.
Applets. An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from a browser You.
26-Jun-15 Applets. 2 An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from.
28-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Tutorial 7 Working with Multimedia. XP Objectives Explore various multimedia applications on the Web Learn about sound file formats and properties Embed.
Mgt 240 Lecture Website Construction: Software and Language Alternatives March 29, 2005.
Introduction to Java Programming. Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
4.1 JavaScript Introduction
JavaScript and The Document Object Model MMIS 656 Web Design Technologies Acknowledgements: 1.Notes from David Shrader, NSU GSCIS 2.Some material adapted.
Tutorial 7 Working with Multimedia. XP Introducing Multimedia Bandwidth is a measure of the amount of data that can be sent through a communication pipeline.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 rfXcel Confidential Copyright 2007 Web Technology JavaScript 12/10/07.
Tutorial 7 Working with Multimedia. XP Objectives Explore various multimedia applications on the Web Learn about sound file formats and properties Embed.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
Applets An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Introduction to Applets Course Lecture Slides 29 th July 2010.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
Tutorial 7 Working with Multimedia. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Explore various multimedia applications.
Tutorial 7 Working with Multimedia. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Explore various multimedia applications.
Java Applets. An applet is a Panel that allows interaction with a Java program. A applet is typically embedded in a Web page and can be run from a browser.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Applets. An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from a browser You.
Java Applets 1. What is an applet? An applet is a small Java program that is typically embedded in a Web page and can be run using the applet viewer or.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
Pravin Yannawar, DOCS, NMU Jalgaon Basic Java : Applets 2 Objectives of This Session Identify the need for Applets Distinguish between Applets and Applications.
Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language) document containing.
JavaScript - A Web Script Language Fred Durao
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 35 – Overview of Java Web Programming Webpage:
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Applets Yong Choi School of Business CSU, Bakersfield.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 Applets are small applications that are accessed on an Internet server, transported over the internet, automatically installed and run as a part of web.
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
1 Applets. 2 What is an applet? Applet: a Java program that can be inserted into a web page and run by loading that page in a browser brings web pages.
CSI 3125, Preliminaries, page 1 Applet. CSI 3125, Preliminaries, page 2 Applet An applet is a Java program that runs in a Web browser. An applet can be.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
CHAPTER Agenda Applets Servelets Browsers HelloWorld.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
Applications Active Web Documents Active Web Documents.
DHTML.
Java Applet.
Section 17.1 Section 17.2 Add an audio file using HTML
Distributed Computing, M. L. Liu
Distributed Computing, M. L. Liu
UNIT-5.
Java Applets.
Introduction to Applet, Application and JDK
11.1 Applets & graphics.
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Enabling Application Delivery Via the Web
G6DICP - Lecture 27 Java Applets.
APPLET PROGRAMMING.
Presentation transcript:

Java Applet & JavaScript SNU OOPSLA Lab. October 2005

Contents  Java Applet  Overview  History  Features of Java Applet  Applet vs. Application  Applet vs. JavaScript  How Java Applet Works  Basic Methods  AWT Components  Example  Online Resources  JavaScript  Overview  History  Features of JavaScript  Pros and Cons  How JavaScript Works  Events  Example  Online Resources

Overview(1/2)  An applet is a software component that runs in the context of another program, e.g. a web browser  A Java applet is an applet written in the Java programming language  Java applets can run in a web browser using a Java virtual machine (JVM), or in Sun’s AppletViewer(a stand alone tool to test applets)  Java applets are platform-independent, in comparison with ActiveX controls

Overview(2/2)  Inheritance Hierarchy of the Applet Class Applet inherits AWT Component class and AWT Container class

History  Java applets were introduced by Sun in 1995  Netscape 2.0 included JVM in 1996  Internet Explorer 3.0 included JVM in 1996  J2SE 5.0 is released recently(2005)

Features of Java Applet  Applets provide interactive features to web applications that cannot be provided by HTML  Web browsers get applet classes from the web site and execute it on local machine  Applets are executed in a sandbox by most web browsers, preventing them from accessing local data  Since Java’s bytecode is platform independent, Java applets can be executed by browsers for many platforms, including Windows, Unix, Mac OS and Linux

Applet vs. Application Java Application  Code size is relatively big  Run independently(on JVM)  Can access to system resources(e.g. Files) Java Applet  Code size is relatively small  Run on browsers(if JRE is installed)  Run in sandbox, ensuring security  Imports java.applet package  Should be a subclass of Applet  Can be imported using, (Internet Explorer) or (Netscape Navigator) tag

Applet vs. JavaScript JavaScript  No need to compile  Can use functions without defining them  Can use variables without defining them  Can be embed in HTML using tags  Users can view source codes Java Applet  Need to compile all the classes  Should define all the methods before using them  Should define all the variables before using them  CLASS/JAR files are needed in addition to HTML  Compiled source codes

How Java Applet Works

Basic Methods(1/2)  Methods for Milestones  init() – initialize the applet  start() – start the applet’s execution  stop() – stop the applet’s execution  destroy() – perform a final cleanup

Basic Methods(2/2)  Typical Structure import java.applet.Applet; import java.awt.Graphics; public class Simple extends Applet {... public void init() {... } public void start() {... } public void stop() {... } public void destroy() {... } public void paint(Graphics g) {... } <APPLET CODE=... CODEBASE=... WIDTH=... HEIGHT=...>...

AWT Components(1/3)  Structure of AWT Component Object Container Panel Applet mouseDown paint update action(deprecated) ScrollPanel Window DialogFrame add/remove setLayout Button CheckBox Label List TextField TextArea Scrollbar

AWT Components(2/3)  Painting Methods(1/2)  public void paint(Graphics g)  is called when the component needing repair  painted area : clip rectangle in the “g” parameter  g - The graphics context to use for painting  public void update(Graphics g)  is called when repaint, update or paint is called  can assume that the background is not cleared  fill background  set the color of the graphics context  calls this component's paint()  g - the specified context to use for updating

AWT Components(3/3)  Painting Methods(2/2)  public void repaint()  repaints this component  causes a call to this component's update() as soon as possible  public void repaint(int x, int y, int width, int height)  repaints the specified rectangle of this component  Summary  repaint()  update()  paint()

Example  Source Code  Result import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello", 50,20); } HelloWorld.java <APPLET CODE="HelloWorld.class “ WIDTH=200 HEIGHT=140> HelloWorld.htm

Online Resources  Java Introduction  Java Tutorial  Using tags in HTML to embed an applet er_guide/using_tags.html

Contents  Java Applet  Overview  History  Features of Java Applet  Main Differences  How Java Applet Works  Basic Methods  AWT Components  Example  Online Resources  JavaScript  Overview  History  Features of JavaScript  Pros and Cons  How JavaScript Works  Events  Example  Online Resources

Overview(1/2)  Language used for adding dynamism to Web pages  Loosely typed – Variables not typed  Object-based – Limited support for inheritance  Interpreted – Interpreter built into browsers  Modeled after C++  Similar syntax  JavaScript can  Put dynamic text into an HTML page  React to events  Read and write HTML elements  Be used to validate data

Overview(2/2)  Object Model in Internet Explorer window plugins document frames history navigator location event screen all anchors applets body embeds images forms filters links plugins styleSheets scripts Collections Objects

History  JavaScript had been known as LiveWire then LiveScript  Sun Microsoftsystems changed its name to JavaScript in 1995  Microsoft released Internet Explorer 3.0 in 1996, which partly supported JavaScript  JavaScript support of earlier versions of Internet Explorer was weaker than Netscape Navigator, but current version of Internet Explorer supports JavaScript well

Features of JavaScript  Dynamism takes three forms 1. Events: Allows you to monitor events and and change positioning or content based on events 2. Dynamic positioning: Can tell the browser where to place content without using tables 3. Dynamic content: Allows dynamic updating of data at specified time intervals

Pros and Cons Pros JavaScript can  Control document appearance and content  Control the behavior of the browser  Interact with document content  Interact with the user  Read and write client state with cookies  Interact with applets  Manipulate embedded images Cons  No graphics capabilities  No reading/writing of files on the client side  No networking except to arbitraty URLs  No multithreading

How JavaScript Works HTML Viewer Executing Scripts

Events  One of the primary uses of Javascript is to make web pages interactive, i.e. responsive to user actions  Javascript provides event handlers  Execute segment of code based on events occurring within the application  Event Listener Types  onload: When a document is loaded  onclick: When the element is clicked  onfocus: When the element is given input focus  onSubmit: When the submit button is clicked  onerror: When the element is not loaded properly

Example(1/3)  Source Code(1/2) Javascript Test function calcTotal(){ tot = document.totalForm.price.value * document.totalForm.qty.value; document.totalForm.total.value = tot; } Simple Example to Show the use of Events Enter a price and move cursor out of box.

Example(2/3)  Source Code(2/2) The new total will be calculated automatically. Price of item: Quantity purchased: The total is:

Example(3/3)  Result

Online Resources  JavaScript Introduction  JavaScript Tutorial  JavaScript Examples and Documents