Java On The Web Session 15. Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet.

Slides:



Advertisements
Similar presentations
GUI Elements Session 17. Memory Upload Layout Components Button TextField TextArea Label Choice Containers Panels The applet itself.
Advertisements

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.
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Java Graphics Section 1 - Multi-File Graphics Programs Section 2 - The Coordinate System and Graphics Context g Section 3 - The Java Drawing and Painting.
Graphics Programming With Applets Feb 23, Applets There are three different types of executable java code. –Standalone application, which has main()
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.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
 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.
©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.
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.
A Simple Applet.
Program Design With Methods And Graphics / Chapter 4 1 Abstract Window Toolkit.
Java Programs u 1 project file –with an extension of.mcp –contains information that CodeWarrior needs to run the program u >= 1 source files –have an extension.
Graphics. Graphics Features in Java Topics to be covered Topics to be covered Graphics Basics Graphics Basics Coordinate System Coordinate System Graphics,
Java Applets. Lecture Objectives  Learn about Java applets.  Know the differences between Java applets and applications.  Designing and using Java.
©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.
© 2007 Lawrenceville Press Slide 1 Chapter 2 HTML An example HTML document Hello world!
Java applet basics, loading & displaying images After this section, you should be able to : –Use the applet tag and applet parameters –Describe what a.
Applets.
JAPPLET.
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.
Object Oriented Programming one of the main reasons we now teach Java instead of C++. C++ was designed to be backwardly compatible with the original (non-OOP)
Java Applet Presented by Fitsum Okubu. Introduction Introduction Graphics Graphics Methods and Variables Methods and Variables Events Events Decision.
Abstract Window Toolkit (AWT) The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include:  A rich set.
Exposure Java-A 2006 Chapter 4 Slides Using Methods and Parameters
Applets & Graphics. Applets programs that run inside a browser Java platform-independence makes applets possible security restrictions: –cannot read or.
Chapter 7 Graphics. © Daly and Wrigley Objectives Use Graphic Components: ▫ Strings ▫ Lines ▫ Rectangles ▫ Ovals ▫ Arcs Change the color and font of elements.
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.
CPS Today’s topics Java Applications Graphics Upcoming Review for Midterm Exam Reading Great Ideas, Chapters 5.
APPLET. 2 Introduction to Java Applet Programs Applications are stand alone programs ◦ executed with Java interpreter Applet is a small program ◦ can.
Applets Yong Choi School of Business CSU, Bakersfield.
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.
עקרונות תכנות מונחה עצמים תרגול 6 - GUI. Outline  Game of Life  Painting.
Chapter 2: Graphics In Java Basics of classes –instance variables –methods –overriding methods Graphics class (drawing routines) Other classes –Color –Font.
1 Contents Introduction Applet Vs Application Security Restrictions on Applet A simple example “Hello World!” applet Compiling & Running Applet HTML document.
Introductory Graphics Chapter Three. Computer Graphics §Full motion pictures (“Star Wars”) l animated films §Virtual reality §Games §Simulators (air craft.
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 Graphics Methods public abstract void drawString(String str, int x, int y): is.
CSI 3125, Preliminaries, page 1 AWT. CSI 3125, Preliminaries, page 2 AWT Java AWT (Abstract Windowing Toolkit) is an API to develop GUI or window-based.
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.
Lec 15 Writing an Applet Class. Agenda Writing an Applet class Java Graphics class.
1 CSC 551: Web Programming Spring 2004 Java Applets  Java vs. C++  instance vs. class variables, primitive vs. reference types, inheritance  graphical.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
Object Oriented Programming one of the main reasons we now teach Java instead of C++. C++ was designed to be backwardly compatible with the original.
The 4 Stages of Program Design  Cryptic Programming Stage  Unstructured, Spaghetti-Programming Stage  Structured Programming Stage  Object Oriented.
The 4 Stages of Program Design  Cryptic Programming Stage  Unstructured, Spaghetti-Programming Stage  Structured Programming Stage  Object Oriented.
CS202 Java Object Oriented Programming GUI Programming – Color and Drawing Methods Chengyu Sun California State University, Los Angeles.
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.
User Interface Programming In Java
Chapter 8 Graphics.
Object Oriented Programming
Applets In Java Visit for more Learning Resources 1.
Java Applets.
Graphics Applets By Mr. Dave Clausen
Today’s topics Java Applications Upcoming Reading Graphics
PowerPoint Presentation Authors of Exposure Java
Chapter 10 Graphics.
Java Applets.
עקרונות תכנות מונחה עצמים
APPLET.
Java Applets.
Chapter 8 Graphics.
Applet in Java.
APPLET PROGRAMMING.
Presentation transcript:

Java On The Web Session 15

Memory Upload JAVA Applets Colors Fonts Drawing Methods Posting your Applet

Applets An applet is a program that runs embedded in HTML code They must be viewed either in  Web Browser  Appletviewer

GUI Elements Applets can display GUI elements  Graphical User Interface Colors Fonts Text-Fields, Button, Labels, etc. Button

Skeleton import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){ } public void paint(Graphics g){ //instructions go here } }

Skeleton import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){ } public void paint(Graphics g){ //instructions go here }

Colors Colors are made out of 3 values Each value goes from 0 to 255  RED  GREEN  BLUE

Colors BlackColor.black0,0,0 BlueColor.blue0,0,255 CyanColor.cyan0,255,255 GrayColor.gray128,128,128 GreenColor.green0,255,0 MagentaColor.magenta255,0,255 OrangeColor.orange255,200,0 PinkColor.pink255,175,175 RedColor.red255,0,0 WhiteColor.white255,255,255 YellowColor.yellow255,255,0

Colors import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){ } public void paint(Graphics g){ //Your Own Color MyColor = new Color(50, 200,150); g.setColor(MyColor); } }

.setColor(Color) g.setColor(Color.yellow); g.setColor(Color.red); g.setColor(MyColor);

Fonts The constructor Font f = new Font(Type, Style, Size); import java.awt.*; import java.applet; public class MyApplet extends Applet { public void init( ){a } public void paint(Graphics g){ Font f=new Font(“Tahoma”,Font.PLAIN, 10); g.setFont(f); } }

Methods void drawLine(int x1, int y1, int x1, int y2) void drawRect(int x, int y, int w, int h) void fillRect((int x, int y, int w, int h) void drawOval(int x, int y, int w, int h) void fillOval(int x, int y, int w, int h) void drawString(String, int x, int y) void drawArc(int x, int y, int w, int h, int start angle, int arcAngle) void fillArc(int x, int y, int w, int h, int start angle, int arcAngle)

The coordinates 0,0 x y

drawLine g.drawLine(10,10,18,24);

0,0 drawRect 8 10 g.setColor(Color.green); g.drawRect(10,10,8,10);

0, fillRect g.setColor(Color.green); g.fillRect(10,10,8,10);

0, drawOval g.setColor(Color.red); g.drawOval(10,10,8,10);

0, fillOval g.setColor(Color.red); g.fillOval(10,10,8,10);

0, drawArc g.setColor(Color.blue); g.drawArc(10,10,8,10,0,45);

0, fillArc g.setColor(Color.blue); g.fillArc(10,10,8,10,0,45);

0,0 drawString g.setColor(Color.Magenta); g.setFont(“Arial”,Font.PLAIN, 30); g.drawString(“Blanca”,10,10); 10 Blanca

Posting Your Applet Write your JAVA code Compile your code Make it available

The Applet Tag <applet CODE="YourClass.class" WIDTH=www HEIGHT=hhh IGNORE=""> Substitute www and hhh for your own width and height. Substitute YourClass.class with the name of your own class. The Applet tag should be regarded as any other html tag inside your HTML page.

Time to Try it Out Applets on the Web

Drawing Applet Skeleton Drawing Methods Colors Fonts Posting Applets in the Web any questions to Memory Defragmenter

Task Manager Post the sample applet from webct on the web, in your website. Read your Visit WebCT, webct.hawaii.edu

Task Manager Post the sample applet from webct on the web, in your website. Read your Visit WebCT, webct.hawaii.edu