DOC PREVIEW
LETU COSC 2103 - Java Applets

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Java AppletsIntroduction to Java Applet ProgramsSlide 3Java Applet ClassesSlide 5Contrast Application with AppletApplet DeclarationBody of an AppletAppletsApplets and Web Pages – HTMLApplets and Web Pages – HTMLSlide 12Slide 13Thinking About ObjectsSlide 15Slide 16A Simple Java Applet: Drawing a StringRunning the AppletRunning the Applet - AlternativelySlide 20Running An AppletSlide 22Java AppletsJava Applets22Introduction to Java Applet Introduction to Java Applet ProgramsProgramsApplications are stand alone programsApplications are stand alone programsexecuted with Java interpreterexecuted with Java interpreterApplet is a small programApplet is a small programcan be placed on a web pagecan be placed on a web pagewill be executed by the web browserwill be executed by the web browsergive web pages “dynamic content”give web pages “dynamic content”33Java AppletsJava AppletsBuilt using one of general definitions of Built using one of general definitions of appletsappletsAppletApplet class classJAappletJAapplet class classJava applets are usually graphicalJava applets are usually graphicalDraw graphics in a defined screen areaDraw graphics in a defined screen areaEnable user interaction with GUI elementsEnable user interaction with GUI elements44Java Applet ClassesJava Applet ClassesAAbstract bstract WWindowing indowing TToolkit oolkit AWTAWTEarlier versions of JavaEarlier versions of JavaAppletApplet class is one of the AWT components class is one of the AWT componentsJJava ava FFoundation oundation CClasses lasses JFCJFCExtension to Java in 1997Extension to Java in 1997Has a collection of Has a collection of Swing componentsSwing components for for enhanced GUIsenhanced GUIsSwing component classes begin with Swing component classes begin with JJ55Java AppletsJava AppletsApplets are Java programs that can be Applets are Java programs that can be embedded in HTML documentsembedded in HTML documentsTo run an applet you must create a .html file which To run an applet you must create a .html file which references the appletreferences the appletReady to ProgramReady to Program also will run an applet also will run an appletWhen browser loads Web page containing appletWhen browser loads Web page containing appletApplet downloads into Web browserApplet downloads into Web browserbegins executionbegins executionCan be tested using appletviewer programCan be tested using appletviewer program66Contrast Application with Applet Contrast Application with Applet Application Applet•Object class extended•Class not declared public•Has a main()•static keyword used•Uses System.exit(1)•JApplet class extended•class declared to be public•init() instead of main()•init() not declared with static keyword77Applet DeclarationApplet DeclarationSyntax (note difference from Syntax (note difference from application application declaration)declaration)public class ClassName extends JAappletpublic class ClassName extends JAapplet ClassName is an object that will be a subclass of JApplet88Body of an AppletBody of an AppletNote there is no Note there is no main()main() method in an method in an appletappletJAppletJApplet class provides other methods instead class provides other methods instead of a of a mainmain method methodFirst method executed is the First method executed is the init()init() methodmethod99AppletsAppletsAppletAppletProgram that runs in Program that runs in •appletviewerappletviewer (test utility for applets) (test utility for applets)•Web browser (IE, Communicator)Web browser (IE, Communicator)Executes when HTML (Hypertext Markup Language) Executes when HTML (Hypertext Markup Language) document containing applet is openeddocument containing applet is openedApplications run in command windowsApplications run in command windowsNotesNotesFocus on fundamental programming concepts firstFocus on fundamental programming concepts first•Explanations will come laterExplanations will come later1010Applets and Web Pages – Applets and Web Pages – HTML HTML Applets embedded in a web pageApplets embedded in a web pageExecuted when web page loaded by browserExecuted when web page loaded by browserWeb pages structured with Web pages structured with HTMLHTML codes codesHHyperyperTText ext MMark-upark-up LLanguageanguageSyntaxSyntax<command><command> . . . . . .</command></command>Turns format onTurns format onTurns the format offTurns the format off1111Applets and Web Pages – Applets and Web Pages – HTMLHTMLEmbedding Java appletsEmbedding Java appletsInsert applet tagsInsert applet tags<APPLET><APPLET></APPLET></APPLET>Call the specific applet by its file nameCall the specific applet by its file name<APPLET CODE = "Whatever.class" <APPLET CODE = "Whatever.class" WIDTH = nnn HEIGHT = mmmm> WIDTH = nnn HEIGHT = mmmm><\APPLET><\APPLET>Where Where nnnnnn and and mmmmmm are specific pixel sizes are specific pixel sizes1212Applets and Web Pages – Applets and Web Pages – HTMLHTMLCreate the web Create the web page code using a page code using a text editortext editorSave it with an Save it with an .html suffix.html suffixOpen this file with Open this file with appletviewer or with appletviewer or with a web browser that a web browser that supports Javasupports JavaJava Plug-in must Java Plug-in must be installed (part of be installed (part of J2SDK 1.4.1 from J2SDK 1.4.1 from Sun)Sun)<HTML><HEAD></HEAD><BODY><APPLET CODE = . . . ></APPLET></BODY></HTML>1313Applets and Web Pages – Applets and Web Pages – HTMLHTMLClient Web browser anywhere can access Client Web browser anywhere can access this web page from its host serverthis web page from its host serverEmbedded Java applet runs on client Embedded Java applet runs on client browser (of any type platform)browser (of any type platform)This means a client anywhere on any type This means a client anywhere on any type of platform can run a piece of software of platform can run a piece of software developed on any other type of platformdeveloped on any other type of platformPlatform Independence1414Thinking About ObjectsThinking About ObjectsJava an object-oriented languageJava an object-oriented languageHowever, Java has constructs from structured However, Java has constructs from structured programmingprogrammingObject orientationObject


View Full Document

LETU COSC 2103 - Java Applets

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download Java Applets
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Java Applets and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Java Applets 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?