1 / 33

LECTURE 18

LECTURE 18. Java and Web Pages. Java Savvy Browser A browser capable of handling java applets: - Netscape Navigator - Microsoft Internet Explorer - Sun Microsystem’s HotJava. HotJava The world’s first Java-savvy browser, developed by Sun Microsysttems. http://java.sun.com/products/hotjava/.

kaethe
Download Presentation

LECTURE 18

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LECTURE 18 Java and Web Pages

  2. Java Savvy BrowserA browser capable of handling java applets:- Netscape Navigator- Microsoft Internet Explorer- Sun Microsystem’s HotJava

  3. HotJavaThe world’s first Java-savvy browser, developed by Sun Microsysttems.http://java.sun.com/products/hotjava/

  4. Gamelanhttp://www.gamelan.comIt is a reference library. It provides links to external pagesmaintained 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 MagazinesJavaWorld - http://www.javaworld.comThe Java Resource Centerhttp://www.idgbooks.com/rc/java

  7. Support AreasJavaSoft http://java.sun.comThe Java FAQ Archiveshttp://www-net.com/java/faq

  8. HTML Tags<HTML>Mountain Twilight <P>Iron Clouds <BR>have moved east.<BR>The mountain is<BR>a black silhouette<BR>the lake<BR>a gold and lavender<BR>bowl of twilight.<BR><PRE> -TFW</PRE></HTML>

  9. HTML TagsCheck:http://www.davesite.comfor information regarding html tags.

  10. HTML Tags<HTML> - Hypertext Markup Language <P> - paragraph break<BR> - line-break<PRE> preformatted information

  11. HTML Tags - Advanced Features<I> - italic <B> - bold<H3> - level 3 heading , range: 1 through 5<H3><B><I>moved east</I></B></H3><IMG> - imageSRC - source<IMG SRC=“coolgraphic.gif”>Hyperlinks<A HREF=“http://www.water.org/lakes.html> lakes </A><A> is called the anchor tag.

  12. Introducing the <APPLET> TagThe <APPLET> tag is used to embed Java applets in Web pages. It is comprised of several parts. Format<APPLET attributes>applet-parametersalternate HTML</APPLET>Example:<APPLET CODE=“Marquee.class” HEIGHT=25, WIDTH=450>

  13. Required Applet AttributesCODE - Specifies the name of the java fileHEIGHT - Specifies the height of the applet in pixelsWIDTH - Specifies the width of the applet in pixels

  14. Optional Applet AttributesALIGN - 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 AttributesCODEBASE - 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:<APPLET CODE=“Marquee.class” HEIGHT = 25 ALT=“ This is a cool applet - too bad you can’t see it!” HSPACE =10 VSPACE=25>

  17. Getting to baseUnder 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<APPLET CODEBASE=“http://www.universal.com/applets/”CODE=“Marquee.class” HEIGHT=25 WIDTH=450>In this example, browsers won’t look for the Marquee applet inside the same directory as the Web page containing this <APPLET> tag. Instead, browsers expect the applet to be located on the universal corporation server, inside the applets directory.

  19. Applet ParametersThe second major part of the applet tag, applet parameters, is where one can really customize an applet.Format:<PARM NAME=“parameter name” VALUE=“parameter value”>

  20. Example:<PARAM VALUE=“sndTrack” VALUE=“audio/summer.au”>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:<PARAM VALUE=“sndTrack” VALUE=“http://www.music.org/audio/summer.au”>

  21. Multiple PARMsDifferent 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:<PARM NAME=“font_face” VALUE=“Helvetica”><PARM NAME=“font_size” VALUE=“24”><PARM NAME=“font_italic” VALUE=“yes”><PARM NAME=“font_bold” VALUE=“yes”>

  23. Alternate HTMLFollowing any parameter tags that you may use, but before the closing </APPLET> tag, there is a special area where you can supply what’s known as alternate HTML.

  24. Example:<APPLET CODE=“LivingLinks” WIDTH=100 HEIGHT=100><PARM NAME=“image” VALUE=“animal.gif”><PARM NAME=“sound” VALUE=“dolphin.au”><PARM NAME=“URL” VALUE=“http://www.universal.com/”><A HREF=“http://www.universal.com/”><IMG SRC=“animal.gif”></A></APPLET>

  25. NOTEThe following lines are the alternate HTML:<A HREF=“http://www.universal.com/”><IMG SRC=“animal.gif”></A>

  26. Combining Java and HTMLimport 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 <HTML><HEAD><TITLE> Test page for Hello Applet</TITLE></HEAD><BODY><HR>This line of text comes before the applet.<P><APPLET CODE = “Hello.class” WIDTH=300 HEIGHT=500></APPLET><P>This line of text comes after the applet.</BODY></HTML>

  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 <APPLET> tag <APPLET CODE=“HelloAgain.class” WIDTH=100 HEIGHT=100 ALIGN=left><PARAM NAME=info VALUE=“How are you?”></APPLET> <APPLET CODE=“HelloAgain.class” WIDTH=100 HEIGHT=100 ALIGN=right><PARAM NAME=info VALUE=“Greetings!”></APPLET>

  30. ImagesGIF - Graphics Interchange FormatJPEG - Joint Photographic Experts Group

  31. GIFThe 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. JPEGGIF 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.

More Related