Outline Character Strings Variables and Assignment

Slides:



Advertisements
Similar presentations
Lecture 2 Internet Computing Using Java Theophano Mitsa UMASS-Dartmouth.
Advertisements

LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Outline Graphics Applets Drawing Shapes Components and Containers Images.
© 2004 Pearson Addison-Wesley. All rights reserved2-1 Introduction to Graphics The last few sections of each chapter of the textbook focus on graphics.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
Chapter Day 5. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 5 Questions from last Class?? Problem set 1 Posted  Introduction on developing.
 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.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Topics  Applets  Classes used for graphics Graphics Point Dimension.
Primitive Types vs. Reference Types Variables of primitive types hold the values of the primitive types directly. Variables of reference types hold references.
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
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.
©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.
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.
COMP 14: Applets June 21, 2000 Nick Vallidis. Announcements zP6 is due Friday.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
Chapter Day 4. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 4 Return Signed Contracts Questions from last Class?? Problem set 1 Posted.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Java Graphics Applets.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Applets and Graphics.
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.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 Object-Oriented Languages.
Object Oriented Programming (OOP) LAB # 5 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
Chapter 5 Graphics. Topics Applets Classes used for graphics –Graphics –Point –Dimension –Color.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
 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.
Introduction to Java Programming CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
©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.
© 2004 Pearson Addison-Wesley. All rights reserved Lecture 2  Chapter 2 CS0401: Intermediate Java Programming.
© 2007 Lawrenceville Press Slide 1 Chapter 2 HTML An example HTML document Hello world!
Applets.
JAPPLET.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Lab 6: Shapes & Picture Extended Ellipse & Rectangle Classes Stand-Alone GUI Applications.
Introduction to Java Applets Sangeetha Parthasarathy 05/21/2001.
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:
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,
1 Objects and Primitive Data  Now we can explore some more fundamental programming concepts  Chapter 2 focuses on: predefined objects primitive data.
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance Java Applets –what is an applet vs. an application? –where do applets.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
Chapter 2 Data and Expressions Part Two. 2-2/30 Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive.
Graphics & Applets CSC 1051 – Data Structures and Algorithms I
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.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
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.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Please open JCreator and follow these steps: 1)Configure  Options 2)JDK Tools 3)Choose Run Applet from drop-down 4)Click Default, then Edit 5)Click the.
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance –information hiding –classes: blueprints for objects Java Applets.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Will not cover Section 3.7 Thinking About Objects: Identifying.
Intro to Graphics from Chapter 2 of Java Software Solutions
Chapter 02 Data and Expressions.
CSC 1051 – Data Structures and Algorithms I
Objects and Classes A class An object (the concept) (the realization)
Java Applets.
title = "Java Software Solutions";
Chapter 2 Data and Expressions.
Chapter 2 Data and Expressions
UNIT-5.
Java Applets.
Java Applets.
Chapter 2 Data and Expressions.
Applet in Java.
Chapter 2 Data and Expressions
Applet 2019/4/23.
Chapter 2 Data and Expressions
Data and Expressions Part Two
G6DICP - Lecture 27 Java Applets.
Drawing Shapes (Graphics Class) Creating Objects Packages
Presentation transcript:

Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes Copyright © 2012 Pearson Education, Inc.

Applets A Java application is a stand-alone program with a main method (like the ones we've seen so far) A Java applet is a program that is intended to be transported over the Web and executed using a web browser An applet also can be executed using the appletviewer tool of the Java SDK An applet doesn't have a main method Instead, there are several special methods that serve specific purposes Copyright © 2012 Pearson Education, Inc.

Applets The paint method is executed automatically whenever the applet’s contents are drawn The paint method accepts a parameter that is an object of the Graphics class A Graphics object defines a graphics context on which we can draw shapes and text The Graphics class has several methods for drawing shapes Copyright © 2012 Pearson Education, Inc.

Applets We create an applet by extending the JApplet class The JApplet class is part of the javax.swing package This makes use of inheritance, which is explored in more detail in Chapter 8 See Einstein.java Copyright © 2012 Pearson Education, Inc.

//******************************************************************** // Einstein.java Author: Lewis/Loftus // // Demonstrates a basic applet. import javax.swing.JApplet; import java.awt.*; public class Einstein extends JApplet { //----------------------------------------------------------------- // Draws a quotation by Albert Einstein among some shapes. public void paint (Graphics page) page.drawRect (50, 50, 40, 40); // square page.drawRect (60, 80, 225, 30); // rectangle page.drawOval (75, 65, 20, 20); // circle page.drawLine (35, 60, 100, 120); // line page.drawString ("Out of clutter, find simplicity.", 110, 70); page.drawString ("-- Albert Einstein", 130, 100); } Copyright © 2012 Pearson Education, Inc.

//******************************************************************** // Einstein.java Author: Lewis/Loftus // // Demonstrates a basic applet. import javax.swing.JApplet; import java.awt.*; public class Einstein extends JApplet { //----------------------------------------------------------------- // Draws a quotation by Albert Einstein among some shapes. public void paint (Graphics page) page.drawRect (50, 50, 40, 40); // square page.drawRect (60, 80, 225, 30); // rectangle page.drawOval (75, 65, 20, 20); // circle page.drawLine (35, 60, 100, 120); // line page.drawString ("Out of clutter, find simplicity.", 110, 70); page.drawString ("-- Albert Einstein", 130, 100); } Copyright © 2012 Pearson Education, Inc.

The HTML applet Tag An applet is embedded into an HTML file using a tag that references the bytecode file of the applet The bytecode version of the program is transported across the web and executed by a Java interpreter that is part of the browser <html> <head> <title>The Einstein Applet</title> </head> <body> <applet code="Einstein.class" width=350 height=175> </applet> </body> </html> Copyright © 2012 Pearson Education, Inc.