ISE 582: Information Technology for Industrial Engineering Instructor: Elaine Chew University of Southern California Department of Industrial and Systems.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 10 Applets.
Advertisements

Computer Science 209 Applets. Applications and Applets A Java application runs on a stand-alone computer and may connect to other computers via sockets.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 18 Applets and Multimedia.
Applets. The Applet Class public class MyApplet extends java.applet.Applet {... /** The no-arg constructor is called by the browser when the Web page.
Review of Java Applets Vijayan Sugumaran Decision and Information Sciences Oakland University.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
1 Applets. 2 Motivations When browsing the Web, you frequently see the graphical user interface and animation developed using Java. These programs are.
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 14 Applets. 2 Knowledge Goals Understand the differing roles of applications and applets Understand how a browser operates Understand the role.
ISE 582: Web Technology for Industrial Engineering University of Southern California DJE Dept of Industrial and Systems Engineering Lecture 7 JAVA Cup.
1 Recitation 11. Applet Applets. An applet is a Java program that is started by a browser (e.g. netscape or internet explorer) when an html file has a.
Applet class The Applet class provides the essential framework that enables applets to be run by a web browser Applet do not have main method Applet depend.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 14 Applets, Images,
ISE 582: Information Technology for Industrial Engineering Instructor: Elaine Chew University of Southern California Department of Industrial and Systems.
ISE 582: Web Technology for Industrial Engineering University of Southern California DJE Dept of Industrial and Systems Engineering Lecture 9 JAVA Cup.
ISE 582: Information Technology for Industrial Engineering Instructor: Elaine Chew University of Southern California Department of Industrial and Systems.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
Applets Java API.
19-Sep-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic : Applets Maj Joel Young
JAVA APPLETS By: Ms. Humaira Siddiqui. Java and the Internet Java is considered to be a language well suited to be used in the internet. In contrast with.
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.
Applets Life Cycle Drawing and Event Handling Methods for UI Components Applet Capabilities Example.
1 INF160 IS Development Environments AUBG, COS dept Lecture 04 Title: Computer Applications (Extract from Syllabus)
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.
Not all java code is an application! Applets, Webstart and Servlets Warning: this is just to show you where to look and some things to look for – by no.
GUI programming Graphical user interface-based programming.
Applets. What is an applet? Why create applets instead of applications? – Applets are Java programs that can be embedded in an HTML document – In contrast,
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 16 Applets and Multimedia.
Java applets. Outline What is Java? Java Applications Java Applets Java Applets Securities Summary.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved GUI: Applets and Multimedia.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Applets and Multimedia.
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.
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.
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.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
1 GUI programming Graphical user interface-based programming Chapter G1 (pages )
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.
Chapter 8 Frameworks. Frameworks Framework is a set of cooperating classes and interface types that structures the essential mechanisms of a particular.
1 Applets. 2 Design of Applets 3 Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded.
1 Applications & Applets Standalone applications & Java applets Peter Mozelius DSV/UCSC.
Applets, Images, and Audio Chapter 14 CSCI CSCI 1302 – Applets, Images, and Audio2 Outline Introduction The Applet Class –The init Method –The start.
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
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.
Introduction to Applets Chapter 21. Applets An applet is a Java application that is intended to be invoked and executed through a Web browser. Click Here.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 28.1 Java Speech API 28.2 Downloading and.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
CS202 Java Object Oriented Programming GUI Programming – Applets Chengyu Sun California State University, Los Angeles.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 17 : Applets King Fahd University of Petroleum & Minerals College of Computer Science.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Applets.
30 Java Applets.
Distributed Computing, M. L. Liu
Distributed Computing, M. L. Liu
Graphical user interface-based programming
UNIT-5.
Introduction to Computing Using Java
Java applets 1/3/2019.
11.1 Applets & graphics.
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
G6DICP - Lecture 27 Java Applets.
Presentation transcript:

ISE 582: Information Technology for Industrial Engineering Instructor: Elaine Chew University of Southern California Department of Industrial and Systems Engineering Lecture 9 JAVA Cup 8: Applets Winston & Narasimhan: Chapt 43-46

30 October 2003Information Technology for IE2 Applets Properties Browser Conventions What Applets Cannot Do What Applets Can Do Accessing Applets from Web Browsers

30 October 2003Information Technology for IE3 Applets: Properties Applets have no main methods. The applet’s size is determined by the html file (no calls to setSize, show). There are no WindowAdapter subclass and no windowClosing method in JApplet classes.

30 October 2003Information Technology for IE4 Changing to an Applet extend JApplet instead of Jframe Remove main method Remove WindowListener and call to addWindowListener, do not import java.awt.event package Constructor need not pass title to super(), eliminate calls to setSize, show Application

30 October 2003Information Technology for IE5 Browser Conventions When a browser loads an applet, it calls: –the constructor –the init method (default init does nothing) –the start method (contains computations to be performed to start the applet) When the applet page is replaced, it calls: –the stop method (also called before destroy) When the applet page is abandoned completely, it calls: –the destroy method

30 October 2003Information Technology for IE6 What Applets Cannot Do Load libraries or define native methods. Read/write files on the host that's executing it. Make network connections except to the host that it came from. Start any program on the host that's executing it. Read certain system properties. Windows that an applet brings up look different than windows that an application brings up.

30 October 2003Information Technology for IE7 What Applets Can Do Play Sounds Make network connections to the host they came from. Cause HTML documents to be displayed. Invoke public methods of other applets on the same page. Applets that are loaded from the local file system have none of the restrictions that applets loaded over the network do. Keep running after you leave their page.

30 October 2003Information Technology for IE8 Calling an Applet from an HTML file When a Java-enabled browser encounters an tag, it: –reserves a display area of the specified width and height for the applet, –loads the bytecodes for the specified Applet subclass, –creates an instance of the subclass, and then –calls the instance's init and start methods.

30 October 2003Information Technology for IE9 Using Resource Locators Why use Resource Locators? The Class class Using the Class class How Resource Locators work Accessing Image Files

30 October 2003Information Technology for IE10 Why Use Resource Locators They find files even after you have moved your program from one directory to another They find files properly not only for standalone applications, but also for browser applications

30 October 2003Information Technology for IE11 The Class class When the JVM loads a class / interface, –it creates a companion “Class” instance The “Class” instance provides –information about the class’s name and instance variables –access to methods for locating resources such as text and image files

30 October 2003Information Technology for IE12 Using the Class class public class MovieAuxiliaries { public static Vector readMovieFile(String fileName) { Vector v = new Vector(); URL url = MovieAuxiliaries.class.getResource(fileName); InputStream stream = (InputStream) (url.getContent()); InputStreamReader reader = new InputStreamReader(stream);... } } Auxiliaries streamreadertokens

30 October 2003Information Technology for IE13 How Resource Locators Work The resource locator starts looking for the file in the same location as the class If the filename includes a relative path, the resource locator will look for the file in the subdirectory of the directory holding that class If the class is part of a browser, this determines the security rules employed Why insist on the same-place restriction?

30 October 2003Information Technology for IE14 Accessing Image Files import java.net.*; import java.awt.image.*; Blah blah blah… public static Image readMovieImage(String fileName) { try { URL url = MovieAuxiliaries.class.getResource(fileName); if (url == null) {return null;} ImageProducer producer = (ImageProducer) (url.getContent()); if (producer == null) {return null;} Toolkit tk = Toolkit.getDefaultToolkit(); Image image = tk.createImage(producer); return image; } catch (IOException e) { System.out.println(e); }; return null; } Blah blah blah… Auxiliaries

30 October 2003Information Technology for IE15 Using Choice Lists A new MovieData class Modifications to the Model side Modifications to the View side Linking the new model and new view Final changes Using a ScrollPane

30 October 2003Information Technology for IE16 MovieDataInterface import java.util.*; public interface MovieDataInterface { // Put movies into data source: public abstract void setMovieVector (Vector v) ; // Extract movies from data source: public abstract Vector getMovieVector () ; // Find a particular movie at given index: public abstract Movie getMovie(int index) ; // Miscellaneous method: public abstract void changed () ; }

30 October 2003Information Technology for IE17 Modifications to the Model Blah blah blah… private MovieData movieData; Blah blah blah… public MovieData getMovieData () { if (movieData == null) { setMovieData(new MovieData ()); } return movieData; } Blah blah blah… public void setMovieData (MovieData m) { movieData = m; movieData.addObserver(new MovieDataObserver(this)); movieData.changed(); } Blah blah blah… Application

30 October 2003Information Technology for IE18 Modifications to the View Blah blah blah… private JList jList; Blah blah blah… public MovieApplication() { getMovie(); getMovieData(); getContentPane().add(“Center”, getMeter()); getContentPane().add(“East”, getJList()); } Blah blah blah… public JList getJList () { if (jList == null) {setJList(new JList());} return jList; } Blah blah blah… public void setJList (JList j) { jList = j; } Application

30 October 2003Information Technology for IE19 Linking Model and View import java.util.*; import javax.swing.*; public class MovieDataObserver implements Observer { private MovieApplication applet; public MovieDataObserver (MovieApplication a) { applet = a; } public void update (Observable observable, Object object) { Vector titles = new Vector(); for (Iterator i = applet.getMovieData().getMovieVector().iterator(); i.hasNext();) { Movie movie = (Movie) (i.next()); titles.add(movie.getTitle()); } applet.getJList().setListData(titles); }

30 October 2003Information Technology for IE20 Linking Model and View import javax.swing.*; import javax.swing.event.*; public class MovieListListener implements ListSelectionListener { private MovieApplication applet; public MovieListListener (MovieApplication a) { applet = a; } public void valueChanged(ListSelectionEvent e) { int index = applet.getJList().getSelectedIndex(); applet.setMovie(applet.getMovieData().getMovie(index)); }

30 October 2003Information Technology for IE21 Final Changes Blah blah blah… public void setMovieData (MovieData m) { movieData = m; movieData.addObserver(new MovieDataObserver(this)); movieData.changed(); } public void setJList (JList j) { jList = j; jList.addListSelectionListener(new MovieListListener(this)); } Blah blah blah… Application

30 October 2003Information Technology for IE22 Using a Scroll Pane Instead of –getContentPane().add(“East”,getJList()); Use –getContentPane().add(“East”,new JScrollPane(getJList()));

30 October 2003Information Technology for IE23 GUI Design: Model-View Approach Class Types Relations Among Class Types Turning the Movie Class into an Observable Class Using the Observer A Meter Listener for MouseClicks RECAP

30 October 2003Information Technology for IE24 Class Types Model Classes: domain knowledge View Classes: information-display Observer / Listener (Adapter) Classes: model-view connections Application Class: –Creates model/view/observer/listener instances –Connects model->(observer)->view and view- >(listener)->model –Establish container-component relations among views