CS100Lecture 181 Announcements P4 due tomorrow P5 handed out today References? Leave me a picture and a short note.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2.
1 CS100J 12 April 2007 Applications and Applets Read Chapter 16 of the text I never let my schooling interfere with my education. Mark Twain Learning makes.
1 Introduction to Applets Overview l What is an Applet? l Steps for creating an applet l What is HTML? l Basic HTML tags l Drawing Simple Graphical shapes.
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.
Applets, Graphical User Interfaces, and Threads / Chapter 9 1 Applets, Graphical User Interfaces, and Threads.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
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.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
Chapter 3 - Introduction to Java Applets Outline 3.1Introduction 3.2Thinking About Objects 3.4A Simple Java Applet: Drawing a String 3.5Two More Simple.
A Simple Applet.
Lecture 17: Animation Yoni Fridman 7/27/01 7/27/01.
Program Design With Methods And Graphics / Chapter 4 1 Abstract Window Toolkit.
Developing User Interfaces (DUI) Chris North cs3724: HCI.
Applets Java API.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Internet Software Development Applets Paul J Krause.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
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.
POS 406 Java Technology And Beginning Java Code
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
1 CS100J 2 December 2008 Applications and Applets Read Chapter 16 of the text We also look at html, since we need it to use applets. Top finalists from.
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.
Applets Applet is java program that can be embedded into HTML pages. Java applets runs on the java enabled web browsers such as mozilla and internet explorer.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Intro to Applets August 19, 2008 Mrs. C. Furman. Java Applets vs. Java Applications Java Applet: a program that is intended for use on the web. Java Applet:
1 Recitation 09. Applications and Applets Java applications Those who took CS100J and CS100M in fall 2003 may not have had much experience with Java applications.
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.
Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language) document containing.
1 CS Nov 2011 Applications and Applets Read Chapter 16 of the text We also look at html, since we need it to use applets. Top finalists from a real-life.
Web Design. How do web pages work? Webpages are written in a code called HTML. Programs like Internet Explorer read the code, and then show it as a web.
Applets Yong Choi School of Business CSU, Bakersfield.
Drawing rectangles and ovals in the Applet window Displaying Text in the Java Console Window Demo of the HelloAgain program Arithmetic expressions Examples.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
25/2/00SEM107 - © Kamin & ReddyClass 9 - HTML - 1 Class 9 - HTML r Creating a personal web page r Structure of HTML documents r HTML tags r The APPLET.
2/5/00SEM107 © Kamin & Reddy Review -1 Class 19 - Review r This lecture contains a selection of slides from previous lectures, giving the “high points”
Applets. Internet/WWW How does it work? Internet/WWW.
Your name CSCI/CMPE 3326 Object-Oriented Programming in Java Dongchul Kim Department of Computer Science University of Texas – Pan American 1.Applet.
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.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
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.
CHAPTER Agenda Applets Servelets Browsers HelloWorld.
1 CS100J 08 November 2005: Applications and Applets Java application; How to produce a stand-alone application, to be run without using DrJava or any such.
Methods.
Lec 15 Writing an Applet Class. Agenda Writing an Applet class Java Graphics class.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
CS 100Lecture 171 Announcements P4 due Thursday FINAL: Tuesday, August 10th, 8AM -- Currently scheduled for Olin 155.
We also look at html, since we need it to use applets.
Java Applet Programming Barry Sosinsky Valda Hilley
Java Course Review.
Object Oriented Programming
Lecture 16: Applets & HTML
We also look at html, since we need it to use applets.
Distributed Computing, M. L. Liu
Distributed Computing, M. L. Liu
UNIT-5.
CS November 2010 Ragged arrays, Applets
Java applets 1/3/2019.
Applet in Java.
Handout-14 Applets and Graphics
We also look at html, since we need it to use applets.
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Enabling Application Delivery Via the Web
CS100J 03 May 2005 Applications and Applets (Chapter 16 of the text)
Presentation transcript:

CS100Lecture 181 Announcements P4 due tomorrow P5 handed out today References? Leave me a picture and a short note

CS100Lecture 182 Today’s Topics Pascal’s Triangle (fun with 2D arrays) Applets Parameter passing -- Examples galore!

CS100Lecture 183 Pascal’s Triangle int [] [] p; p = new int[7][]; // p.length is 7 p[0] = new int[1];// p[0].length is 1 p[1] = new int[2];// p[1].length is 2 p[2] = new int[3];// p]2].length is 3 Note : Elements of an array can be arrays of different lengths!

CS100Lecture 184 Compute Pascal’s Triangle // Yield Pascal's triangle with size rows public static int[][] calculatePascal(int size) { int[][]p= new int[size][]; //the triangle for (int r= 0; r != size; r= r+1) { // Allocate row i of triangle --its r+1 values p[r]= new int[r + 1]; // Calculate row r of Pascal's triangle p[r][0]= 1; for (int c= 1; c < r; c= c+1) p[r][c]= p[r-1][c-1] + p[r-1][c]; p[r][r]= 1; } return p; }

CS100Lecture 185 Java and World Wide Web HTML is the language in which files (or pages) are written for the world wide web. Internet Explorer and Netscape, the two most used browsers, read html files and display them on the screen. Example html file: This goes at the top of the page This is a new paragraph. this is in italics. This is in bold but this isn’t. A new paragraph in a larger font

CS100Lecture 186 HTML is a markup language begins a command, ends it. There are commands for paragraphs, new line, font change, font-style change, lists, tables, and many more. Cornell’s page produces a link on the page: Cornell’s page

CS100Lecture 187 Applets in html Command applet: <applet archive=AppletClasses.jar code=“className.class” width=200 height=400 Execute a java program. The window for it is 200 x 400. All of the classes in it are in file AppletClasses.jar. The class to begin execution is in file className.class. Many examples of applets. To see one, bring up page click on CSFacts, and click to get to “Faculty over the years”

CS100Lecture 188 Applets and OO Applets are a good advertisement for object oriented programming Your classes inherit from Applet Applet contains all the details of how an applet works and interacts with the system So you can just worry about what you want your applet to do Note: no main method, already inside a running program when applet is invoked.

CS100Lecture 189 Example: import java.awt.*; import java.applet.Applet; public class TrivialApplet extends Applet {public void init() { repaint();} public void paint( Graphics g ) { g.drawString( "Hello World!", 10, 10 ); g.drawString("Parking", 50, 50); g.drawOval(45, 24, 43, 43); g.drawLine(82,30,51, 61); }}

CS100Lecture 1810 Html for this applet: TrivialApplet The source.

CS100Lecture 1811

CS100Lecture 1812 Graphics Applets are most useful if you employ graphics Check out the package java.awt in the Java API -- lots of graphics classes there. Remember -- you can use all the programming techniques you’ve learned so far (loops, ifs, method calls, etc. etc.) when you’re writing applets - this was just a trivial example.

CS100Lecture 1813 Method Invocation 0. Allocate a new set of locations to contain the parameters and local variables of the method being called, in what we call a frame. 1. Assign the arguments of the call to the parameters of the method. 2. Execute the procedure body. 3. Delete the frame produced in step 0; if the method is a function, return the value of the function to the place of call. Terminology: parameter: formal parameter argument: actual parameter MAKE THE SPACE ASSIGN (COPY!) ARGUMENTS TO PARAMETERS RUN THE METHOD DELETE FRAME RETURN VALUE

CS100Lecture 1814 Parameter-Passing Redux public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(); c.myMethod(x, y); System.out.println("x = " + x + " y = " + y);} } public class C { public void myMethod(int a, int b) { a = 3; b = 4;} }

CS100Lecture 1815 Names and boxes public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(); c.myMethod(x, y); System.out.println("x = " + x + " y = " + y);} } public class C { public void myMethod(int x, int y) { x = 3; y = 4;} }

CS100Lecture 1816 Names and boxes, 2 public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(); c.myMethod(x, y); System.out.println("x = " + x + " y = " + y);} } public class C { public void myMethod(int y, int x) { x = 3; y = 4;} }

CS100Lecture 1817 Complications public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(x, y); c.myMethod(c.x, c.y); System.out.println("x = " + x + " y = " + y);}} public class C { int x; int y; public C(int xx, int yy) {x = xx; y = yy;} public void myMethod(int a, int b) { a = 3; b = 4;} }

CS100Lecture 1818 Complications, 2 public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(x, y); c.myMethod(); x = c.x; y = c.y; System.out.println("x = " + x + " y = " + y);}} public class C { int x; int y; public C(int xx, int yy) {x = xx; y = yy;} public void myMethod() { x = 3; y = 4;} }

CS100Lecture 1819 Complications, 3 public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(); c.myMethod(x, x); System.out.println("x = " + x + " y = " + y);} } public class C { public void myMethod(int y, int x) { x = 3; y = 4;} }

CS100Lecture public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(x, y); c.myMethod(c); x = c.x; y = c.y; System.out.println("x = " + x + " y = " + y);}} public class C { int x; int y; public C(int xx, int yy) {x = xx; y = yy;} public void myMethod(C d) { d.x = 3; d.y = 4;} }

CS100Lecture 1821 public class TrivialApplication { public static void main(String args[]) { int x = 1; int y = 2; C c = new C(x, y); c.myMethod(c); x = c.x; y = c.y; System.out.println("x = " + x + " y = " + y);}} public class C { int x; int y; public C(int xx, int yy) {x = xx; y = yy;} public void myMethod(C d) { x = 3; y = 4;} }