LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.

Slides:



Advertisements
Similar presentations
Applets and Graphics.
Advertisements

Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Made with love, by Zachary Langley Applets The Graphics Presentation.
1 More on Applets Overview l Changing Colors l Changing Fonts & Styles l Applet Life-Cycle l Input using Dialog Window l Input using HTML parameters l.
Frame Windows A frame object is used to create a graphical frame window. This frame is used to show information in a graphical application. The JFrame.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 21.
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
Graphics Programming. Introduction GOAL: Build the Indexer Client Event-driven vs. Sequential programs Terminology – Top-level windows are called “frame.
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Applets Graphical Java programs Run inside web browser Platform-neutral Easy deployment--loads when needed Secure.
Java Graphics Section 1 - Multi-File Graphics Programs Section 2 - The Coordinate System and Graphics Context g Section 3 - The Java Drawing and Painting.
© 2004 Pearson Addison-Wesley. All rights reserved2-1 Introduction to Graphics The last few sections of each chapter of the textbook focus on graphics.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
©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.
2D Graphics in Java COMP53 Nov 14, Applets and Applications Java applications are stand-alone programs – start execution with main() – runs in JVM.
©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.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
©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.
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.
Program Design With Methods And Graphics / Chapter 4 1 Abstract Window Toolkit.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Graphics. Graphics Features in Java Topics to be covered Topics to be covered Graphics Basics Graphics Basics Coordinate System Coordinate System Graphics,
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Computer Science [3] Java Programming II - Laboratory Course Lab 6: Introduction to Java Applets Sample Applets from the Java Simple Java Applet: Drawing.
©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.
Agenda For Feb Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages ) then.
Java Software Solutions Lewis and Loftus Chapter 7 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphics -- Introduction The.
Java On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet.
User-defined parameters can be passed to an applet using the tags.
Applets & Graphics. Applets programs that run inside a browser Java platform-independence makes applets possible security restrictions: –cannot read or.
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 Applets and Course Evaluation Applet Example - Sailing Applet UML Diagrams Applet Web Page Encoding (HTML) Applet Java Coding – Hello World Course Evaluation.
Lecture 8.3 The Use of JComponent. © 2006 Pearson Addison-Wesley. All rights reserved More About the Standard Drawing Classes java.awt.Container.
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:
Introduction to Java Simple Graphics. Objects and Methods Recall that a method is an action which can be performed by an object. –The action takes place.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
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.
Graphics & Applets CSC 1051 – Data Structures and Algorithms I
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Merete S COLLEGEFACULTY OF ENGINEERING & SCIENCE Graphics ikt403 – Object-Oriented Software Development.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Painting (Chapter 12) Java Certification Study Group January 25, 1999 Mark Roth.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
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.
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.
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.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Will not cover Section 3.7 Thinking About Objects: Identifying.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Applet: An applet is a java program that is transmitted over the network from the server to client & executed within clients browser. Applets are used.
Intro to Graphics from Chapter 2 of Java Software Solutions
CSC 1051 – Data Structures and Algorithms I
Distributed Computing, M. L. Liu
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
Graphics -- Introduction
Java applets 1/3/2019.
Outline Character Strings Variables and Assignment
Drawing Shapes (Graphics Class) Creating Objects Packages
Presentation transcript:

LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class

Two types of Java programs JAVA PROGRAM JAVA APPLET JAVA APPLICATION

Java applet is a java program that is intended to be embedded into a html document,tansported across a network and executed using a web browser. Java application is a standalone program that can be executed using a java interpreter

Execution of an applet An applet may be viewed locally either using an web Browser Or it can be run using a tool in java SDK (software development kit) called the APPLET VIEWER.

Example PROGRAM Import java.applet.Applet; import java.awt.*; Public class applet1 extends Applet { Public void paint(Graphics g) { g.drawString(“This is my first applet”,100,50); }

Graphics class A graphics object defines a particular graphics context with which we can interact. A graphics context passed into a paint method represents the entire applet window Each graphics context has its own coordinate system

Embedding a applet in HTML file <applet code=“applet1.class” width=350 height=200> Append this statement in your html file and place the.class file in your folder which contains this html file. Then this applet is downloaded and executed by web browser when u run the html file

Graphics class The graphics class is present in java.awt package. It contains various methods that allow us to draw shapes,including lines,rectangle,etc.

Methods in graphics class Void drawLine(int x1,int x2,int y1,int y2) Paints a line from point(x1,y1) to (x2,y2). (x1,y1) (x2,y2)

Draw rectangle Void drawRect(int x1,int x2,int width,int height) Void fillRect(int x1,int x2,int width,int height) Paints a rectangle with upperleft corner(x,y) and dimensions width and height Fills the rectangle with current foreground color (x1,y1) width height

Draw string Void drawString(String string,int x1,int x2); Paints the message at specified coordinates (x1,y1) string

Color class methods Color getColor() returns the graphics context current foreground color Void setColor(Color color) Sets the graphics context foreground color setBackground(Color color)//method in applet class sets the background of applet to specified color

Draw oval Void drawOval(int x1,int y1,int width,int height) Paints an oval bounded by an rectangle with an upper left corners (x,y) and dimensions width and height Void fillOval(int x1,int y1,int width,int height) (x1,y1) height width