Lecture 16: Applets & HTML

Slides:



Advertisements
Similar presentations
Internet Services and Web Authoring (CSET 226) Lecture # 5 HyperText Markup Language (HTML) 1.
Advertisements

WeB application development
Anne McGrath 16 th February  Review of what we have learned so far.  Angled brackets surround HTML tags.  The words between the angled brackets.
Java Applets A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
 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 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.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
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.
Lecture 17: Animation Yoni Fridman 7/27/01 7/27/01.
Basic HTML Workshop LIS Web Team Fall What is HTML? Stands for Hyper Text Markup Language Computer language used to create web pages HTML file =
Computer Science 101 HTML. World Wide Web Invented by Tim Berners-Lee at CERN, the European Laboratory for Particle Physics in Geneva, Switzerland (roughly.
HTML (HyperText Markup Language)
Chapter 4: Hypertext Markup Language Primer TECH Prof. Jeff Cheng.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
Just Enough HTML How to Create Basic HTML Documents.
HTML Hyper Text Markup Language. What is an HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup.
HTML INTRODUCTION. What is HTML?  HTML stands for Hypertext Markup Language  Developed in 1990  Hidden code that helps us communicate with others on.
Chapter 8 Introduction to HTML and Applets Fundamentals of Java.
CS105 INTRODUCTION TO COMPUTER CONCEPTS HTML Instructor: Cuong (Charlie) Pham.
HTML: Hyptertext Markup Language Doman’s Sections.
Lec.10 + (Chapter 8 & 9) GUI Java Applet Jiang (Jen) ZHENG July 6 th, 2005.
Ali Alshowaish. What is HTML? HTML stands for Hyper Text Markup Language Specifically created to make World Wide Web pages Web authoring software language.
Introduction to HTML Xiangming Mu 9/23/ Learning Objectives Understand basic HTML tags and their attributes Learn to create a simple HTML page.
LEARNING HTML PowerPoint #1 Cyrus Saadat, Webmaster.
Introduction to Computers 12/6/ BEGINNING HTML DESIGNING YOUR OWN WWW PAGES.
HTML. Hyper Text Markup Language Markup your text document The markup is the tag Hyper text means you can jump from place to place.
HTML Basic. What is HTML HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language, it.
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
Basic HTML Programming Technology Education Ellsworth Community Middle School Communication Systems.
What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup.
Your HTML website creating your first html file. Creating an HTML FIle Open note pad from accessories, programs. Write code. Save and view. In 3 Steps.
HTML. INDEX Introduction to HTML Creating Web Pages Commands And Tags Web Page.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Will not cover Section 3.7 Thinking About Objects: Identifying.
1 Introduction to HTML. 2 Definitions  W W W – World Wide Web.  HTML – HyperText Markup Language – The Language of Web Pages on the World Wide Web.
What you can see in the picture?
Online PD Basic HTML The Magic Of Web Pages
INTRO TO WEB DEVELOPMENT html
Introduction to HTML.
Chapter 8 Introduction to HTML and Applets
HTML Basics.
Internet Exploration: HTML Basics
Marking Up with XHTML Tags describe how a web page should look
Introduction to HTML.
Elements of HTML Web Design – Sec 3-2
HTML.
CSCI-235 Micro-Computers in Science
Creating a Home Page in HTML
Internet Exploration: HTML Basics
Elements of HTML Web Design – Sec 3-2
Web Programming– UFCFB Lecture 5
Tag Basics.
COMPUTING FUNDAMENTALS
Distributed Computing, M. L. Liu
Distributed Computing, M. L. Liu
Marking Up with XHTML Tags describe how a web page should look
Marking Up with XHTML Tags describe how a web page should look
Java applets 1/3/2019.
What is HTML anyway? HTML stands for HyperText Markup Language. Developed by scientist Tim Berners-Lee in 1990, HTML is the "hidden" code that helps us.
Internet Technologies I - Lect.01 - Waleed Ibrahim Osman
Html.
Basic HTML Workshop.
Marking Up with XHTML Tags describe how a web page should look
Pertemuan 1 Desain web Pertemuan 1
HyperText Markup Language
Marking Up with XHTML Tags describe how a web page should look
Handout-14 Applets and Graphics
AN INTRODUCTION BY FAITH BRENNER
Lesson 3: Organizing your material
Marking Up with XHTML Tags describe how a web page should look
Presentation transcript:

Lecture 16: Applets & HTML Yoni Fridman 7/26/01

Outline What is an applet? Writing applets HTML Executing an applet The paint() method HTML Tags Images Links The APPLET tag Executing an applet

What is an Applet? So far, whenever we’ve compiled a program, we’ve created an application. Now, we’re going to create applets – what’s the difference? Application A stand-alone executable that can be run from anywhere. Execution is controlled by the main() method. Is written from scratch. No security restrictions. Applet Must be run from a web browser, using an HTML file. No main() method – execution is controlled by the browser. Extends the Applet class. Can’t normally read/write files.

Writing Applets For any applet, we must first import java.applet.Applet (as well as java.awt.*). After our class name, we must add extends Applet. Why? Example: public class TicTacToe extends Applet This says that our new class is a subclass of the Applet class. Every instance method already defined in the Applet class is automatically an instance method of our new class. (We say that our class inherits methods from the Applet class.)

The paint() Method The most important instance method that we inherit from the Applet class is the paint() method. Every applet we write will have a method named paint(). It’s return type will be void, and it will take one argument – a graphics context: public void paint(Graphics g) All of the drawing methods that we use (drawLine(), drawRect(), fillOval(), etc.) will be called from within the paint() method.

A Side Note If the paint() method is already defined in the Applet class, why are we defining it in our class? When we run an applet from a web browser, the paint() method will be called automatically (kind of like the main() method). Furthermore, when it’s automatically called, it’s given a graphics context as an argument. The paint() method defined in the Applet class has an empty body – we override it with a method that does what we want.

HTML What is HTML? HTML is not a programming language. It stands for hyper-text markup language. Hyper-text: Text seen on a web that takes you to a link when you click on it. Markup: To modify and/or format plain text (for example, make bold, underline, indent, add links, etc.). Language: Not much to explain here. Translation: HTML is a language that’s used to format text and add links.

Tags HTML is based on tags, which are simple formatting commands. Tags are always placed within triangle brackets. Example: <B> is the tag that makes text bold. Tags usually come in pairs, and surround the text to be formatted. The 2nd tag has a / right before it. Example: <B>Hello everyone</B> will make the text “Hello everyone” bold. HTML is not case sensitive – <b> and <B> are the same.

Tags

Tags Some tags that should be in every HTML file: <HTML></HTML> – The HTML tag surrounds everything. The two parts go at the very beginning and end of the page. <HEAD></HEAD> – The HEAD tag surrounds the introduction of the HTML file. <TITLE></TITLE> – The TITLE tag surrounds the text that will be displayed in the title bar of the web browser. <BODY></BODY> – The BODY tag surrounds everything that you want displayed in the web page.

Example For example, a basic HTML file might look like this. <HEAD> <TITLE>My Web Page</TITLE> </HEAD> <BODY> <B>Hi.</B> This is my web page. </BODY> </HTML>

List Tags You can make two different kinds of lists in HTML. Unordered (bulleted) lists are surrounded by the <UL></UL> tag. Ordered (numbered) lists are surrounded by the <OL></OL> tag. In both types of lists, each list item is surround by the <LI></LI> tag. Example: <UL> <LI>Item 1</LI> <LI>Item 2</LI> <LI>Item 3</LI> </UL>

Images You can load any image into a web page using the <IMG> tag: <IMG SRC=“The URL of the image you want”> URL stands for uniform resource locator – it’s just a web address. So to load an image, the image must have a valid web address – this address gets placed inside the double quotes in the <IMG> tag. If the image is in the same directory as the HTML file, simply put its name in the double quotes.

Changing the Background You can change the background of your web page by adding stuff to the <BODY> tag. To use an image to “wallpaper” your background: <BODY BACKGROUND=“Image’s URL”> To change the color of your background (to red, for example): <BODY BGCOLOR=RED> or <BODY BGCOLOR=“FF0000”> What does “FF0000” mean?

Another Side Note FF0000 is the RGB value of red in hexadecimal. We’ve seen binary (numbers base 2) and we know decimal (numbers base 10). Hexadecimal is numbers base 16. The digits of hexadecimal are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A(10), B(11), C(12), D(13), E(14), F(15). In decimal, 255 = 2*100 + 5*10 + 5*1. In hexadecimal, FF = 15*16 + 15*1 = 255. In binary, 11111111 = 128*1 + 64*1 + 32*1 + 16*1 + 8*1 + 4*1 + 2*1 + 1*1. So FF, 00, 00 is 255, 0, 0 – the RGB value of red.

Links (Hyper-text) You can make a link by using the <A></A> tag: <A HREF=“The URL of the link”>Hyper-text</A> (HREF stands for hyper reference.) For example, if I wanted to make a link to espn.com from my home page, I would need the following line of HTML: <A HREF=“http://www.espn.com”>ESPN</A> Then my home page would display ESPN.

The APPLET Tag The <APPLET></APPLET> tag is used to execute an applet from a web page. It’s format looks like this: <APPLET CODE=“XXX.class” WIDTH=XXX HEIGHT=XXX></APPLET> The second and third sets of X’s get replaced with the desired width and height of your applet, in pixels. The first set of X’s gets replaced with the name of your Java class. This command is what executes your applet, by loading the .class file. You can also pass arguments to an applet: Example: <APPLET CODE=“TicTacToe.class” WIDTH=400 HEIGHT=400> <PARAM NAME=“BOARD_SIZE” VALUE=350> </APPLET>

Executing an Applet To execute an applet Write an applet in Visual J++. Write a plain text HTML file (using any word processor) that contains the <APPLET></APPLET> tag. The name of the HTML file must end in either .html or .htm. Method 1 Place your HTML file in the same directory as your Java project. Run your program. The first time you run it, DO NOT check the box labeled “Launch as a console application.” Method 2 Place your HTML file and your .class file in the same directory. Load your HTML page by either: Double-clicking on it; or Opening it from the File menu of a web browser.

Homework Read: 12.3, to the top of page 497.