Applet 2019/4/23.

Slides:



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

Java Applets:. How Applets differ from application?: They do not use main method but init(), start() and paint() methods of the applet class They can.
1 Outline Chapter 4 Introduction Control Structures if Single-Selection Statement if else Selection Statement while Repetition Statement Assignment Operators.
Java Applets A First Program. Applet Example /* The world’s simplest program, repeated once more in another format in an attempt to turn all of you into.
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.
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.
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.
 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.
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.
 2002 Prentice Hall. All rights reserved. 1 Week 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2 Software.
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.
Applets. What is an Applet?  According to Sun “An applet is a small program that is intended not to be run on its own, but rather to be embedded inside.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Object Oriented Programming (OOP) LAB # 5 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 24 - Introduction to Java Applications and Applets Outline 24.1Introduction 24.2Basics of a Typical.
 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 First Semester,
1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2 Software Development Kit The TicTacToe Applet.
Computer Science [3] Java Programming II - Laboratory Course Lab 6: Introduction to Java Applets Sample Applets from the Java Simple Java Applet: Drawing.
 2002 Prentice Hall. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2 Software.
10/25: Methods & templates Return to concepts: methods Math class methods 1 st Program of the day About DrawLine.java modifications Method definitions.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
JAPPLET.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
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.
Chapter 3 Introduction to Java Applets 1 3 There is no main method in a Java Applet. A Java Applet can only run in a browser. An Applet is run.
1 Applets and Course Evaluation Applet Example - Sailing Applet UML Diagrams Applet Web Page Encoding (HTML) Applet Java Coding – Hello World Course Evaluation.
Java I--Copyright © Tom Hunter. Chapter 3 Introduction to Java Applets.
10/11: do/while, Logical Operators the revised SwitchTest.java notes on JApplets the do / while repetition structure break continue Logical operators.
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:
SLINGSHOT PROJECT By Dale Henderson Jarly López Robert Kemp Stacey Cotty.
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,
习 题 4.23 编写一个 applet ,读取一个矩形的边长,然后 用在 paint 方法中使用 drawString 方法画出用星组成 的空心矩形。程序应能画出边长从 1 到 20 的任何矩 形。
Review of CIS 120 Concepts: What you said you want….
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
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,
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1Introduction 3.2Thinking About Objects 3.3Sample.
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.
 2002 Prentice Hall. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2 Software.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1 Introduction 5.2 Essentials of Counter-Controlled.
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 Applications & Applets Standalone applications & Java applets Peter Mozelius DSV/UCSC.
Creating a Java Application and Applet
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.
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.
9/13: 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 Outline 3.1 Introduction 3.2 Sample Applets from the Java 2.
Topic: Applets Course : JAVA PROGRAMMING Paper Code: ETCS-307
User Interface Programming In Java
Chapter 3 - Introduction to Java Applets
Java I.
UNIT-5.
Chapter 24 - Introduction to Java Applications and Applets
Constructor Laboratory /12/4.
Java Applets.
Chapter 3 - Introduction to Java Applets
I/O and Applet from Chapter 12
Handout-14 Applets and Graphics
Debugging Exercise 00 Try compiling the code samples.
Outline Character Strings Variables and Assignment
APPLET PROGRAMMING.
Presentation transcript:

Applet 2019/4/23

Applet So far we have focused on Java programs. Another type of program is the applet. Applets are small applications that are accessed on an Internet Server, transported over the Internet. Next page is the simple applet. This applet begins with two import statements. 2019/4/23

It declares a new class called MyApplet Format you can write the simplest Java applet in only a few lines of code, as follows: import java.applet.*; public class MyApplet extends Applet { …… } tells the Java compiler that this applet will be using some or all of the classes defined in the applet package It declares a new class called MyApplet 2019/4/23

A simple applet (1) Step SimpleApplet 1 Create a HTML that executes SimpleApplet 2 lecture12h.htm 3 2019/4/23

A simple applet (2) 4 Applet Use appletviewer to run it. Appletviewer lecture12h.htm 4 Applet 2019/4/23

Using IE Explorer to browse lecture12h.htm Applet 2019/4/23

Two Lines 2019/4/23

Laboratory 2 – input and output 2019/4/23

Comparison for three numbers maximum Max 2 Max 1 Number 4 Number 5 Number 6 Number 1 Number 2 Number 3 2019/4/23

Laboratory /* This Applet reads nine numbers, number0, number1, and number2, number3, number4, number5, number6, number7, number8; and prints the largest value and the samllerest value. */ import java.awt.Graphics; // import class Graphics import javax.swing.*; // import package javax.swing public class lab5 extends JApplet { double max; double min; double max0; double min0; double max1; double min1; double max2; double min2; // initialize applet by obtaining values from user public void init() { String numberOne; String numberTwo; String numberThree; ……………….. double number0; double number1; double number2; …………………. numberOne = JOptionPane.showInputDialog( "Enter first floating-point value" ); ………………. number0 = Double.parseDouble( numberOne ); ………………… // Determine largest value for num 1 to 3 max0 = number0; if (number1 > max0) max0 = number1; if (number2 > max0) max0 = number2; // Determine largest value for num 4 to 6 max1 = number3; if (number4 > max1) max1 = number4; if (number5 > max1) max1 = number5; ……………………… // Determine largest value for num 1 to 9 i.e. max 0 to 2 max = max0; if (max1 > max) max = max1; if (max2 > max) max = max2; …………………… } // end method init // draw results in a rectangle on applet background public void paint( Graphics g ) // call superclass version of method paint super.paint( g ); // draw rectangle starting from (15, 10) that is 270 // pixels wide and 20 pixels tall g.drawRect( 15, 10, 270, 20 ); // draw results as a String at (25, 25) g.drawString( "Largest value is " + max + " ,Smallest is " + min, 25, 25 ); } // end method paint } // end class MaxMin9Applet 2019/4/23