Download presentation
Presentation is loading. Please wait.
Published byMaurice Baldwin Modified over 9 years ago
1
LECTURE 18 Java and Web Pages
2
Java Savvy Browser A browser capable of handling java applets: - Netscape Navigator - Microsoft Internet Explorer - Sun Microsystem’s HotJava
3
HotJava The world’s first Java-savvy browser, developed by Sun Microsysttems. http://java.sun.com/products/hotjava/
4
Gamelan http://www.gamelan.com It is a reference library. It provides links to external pages maintained by the applet and script authors.
5
Java Applet Rating Service (JARS) JARS maintains hyperlinks to external Java-powered pages, as Gamelan does, and also ranks the applets in each page it points to.
6
Javazines: Electronic Magazines JavaWorld - http://www.javaworld.com The Java Resource Center http://www.idgbooks.com/rc/java
7
Support Areas JavaSoft http://java.sun.com The Java FAQ Archives http://www-net.com/java/faq
8
HTML Tags Mountain Twilight Iron Clouds have moved east. The mountain is a black silhouette the lake a gold and lavender bowl of twilight. -TFW
9
HTML Tags Check: http://www.davesite.com for information regarding html tags.
10
HTML Tags - Hypertext Markup Language - paragraph break - line-break preformatted information
11
HTML Tags - Advanced Features - italic - bold - level 3 heading, range: 1 through 5 moved east - image SRC - source Hyperlinks lakes is called the anchor tag.
12
Introducing the Tag The tag is used to embed Java applets in Web pages. It is comprised of several parts. Format applet-parameters alternate HTML Example:
13
Required Applet Attributes CODE - Specifies the name of the java file HEIGHT - Specifies the height of the applet in pixels WIDTH - Specifies the width of the applet in pixels
14
Optional Applet Attributes ALIGN - Specifies where the applet is placed on the page in respect to the text around it: left, right, top, texttop, middle, bottom, absbottom, and baseline. ALT - This attribute specifies alternative text to be displayed if the Java-savvy browser is incapable of executing the applet for whatever reason. If you want to communicate with non-Java browsers, do so by using alternate HTML.
15
Optional Applet Attributes CODEBASE - This attribute specifies the base URL for the applet. The applet must be located relative to this URL. If CODEBASE isn’t specified, the applet is expected to reside in the same directory as the Web page. HSPACE - This attribute specifies the horizontal space surrounding your applet. NAME - This attribute specifies the symbolic name of the applet, allowing other applets embedded in the same page to locate your applet by name. VSPACE - This attribute specifies the vertical space surrounding your applet.
16
Example:
17
Getting to base Under normal conditions, the browser expects to find the applet file inside the same directory as the Web page. However, keeping the applet and the Web page in the same directory isn’t always possible. The optional CODEBASE tag enables you to specify a URL that points to the directory containing your applet. When a Java-savvy browser encounters the CODEBASE attribute, it automatically knows to look for the applet in the whatever directory that attribute points to.
18
Example In this example, browsers won’t look for the Marquee applet inside the same directory as the Web page containing this tag. Instead, browsers expect the applet to be located on the universal corporation server, inside the applets directory.
19
Applet Parameters The second major part of the applet tag, applet parameters, is where one can really customize an applet. Format:
20
Example: In this example, the name of the parameter is sndTrack. The value associated with this parameter, audio/summer.au, is a relative URL( a partial URL pointing to a file or image located relative to the Web page in which the applet itself appears) leading to a sound file. Some applets may also accept an absolute URL (complete URL provided) for this parameter:
21
Multiple PARMs Different applets may support any number of different parameters. It’s not unusual, for example, to come across applets that support several different parameters, giving one great flexibility when it comes to configuring them. To supply more than one parameter, all you have to do is enter the parameters one after another.
22
Example:
23
Alternate HTML Following any parameter tags that you may use, but before the closing tag, there is a special area where you can supply what’s known as alternate HTML.
24
Example:
25
NOTE The following lines are the alternate HTML:
26
Combining Java and HTML import java.applet.*; import java.awt.*; public class Hello extends Applet { Label helloLabel = new Label (“Hello everyone…”); public void init( ){ setBackground(Color.yellow); add(helloLabel); } }
27
Putting an Applet on the Page Test page for Hello Applet This line of text comes before the applet. This line of text comes after the applet.
28
Passing Parameters import java.applet.*; import java.awt.*; public class HelloAgain extend Applet{ Label helloLabel = new Label( ) String infoString = “null”; public void init( ) { infoString = getParameter(“info”); helloLable.setText(infoString); add(helloLabel); } }
29
The tag
30
Images GIF - Graphics Interchange Format JPEG - Joint Photographic Experts Group
31
GIF The GIF format is great at compressing cartoon-like artwork, but not nearly as good as JPEG for compressing photographic quality images. Interlacing is another feature unique to the GIF format. It enables images to be incrementally drawn on-screen as they come across the wire, so viewers don’t have to wait until the entire image is transmitted.
32
JPEG GIF images are currently limited to 256 (8-bit) colors. The JPEG format, on the other hand, supports over 16 million (24-bit) different colors. As a general rule, you should keep the total amount of material to be downloaded per page (text, graphics, sound files, applets, and so on) under 250K.
33
JPEG If you have a large number of graphics and more than 250K in total Web page material, consider using the JPEG format simply to gain the highest degree of compression possible. Because images with more than 100 colors tend to compress more efficiently in the JPEG format than with GIF, target those images with the most colors first for JPEG. Interlacing is not support by JPEG at the moment.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.