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 Applets2Introduction to Java Applet Programs•Applications are ___________________ programs–executed with Java interpreter•Applet is a small program–can be placed on a ___________–will be executed by the web ____________–give web pages “___________ content”3Java Applets•Built using one of general definitions of applets–Applet class–JAapplet class•Java applets are usually __________–Draw graphics in a defined screen area–Enable user interaction with ______ elements4Java Applet Classes•Abstract Windowing Toolkit AWT–Earlier versions of Java–_________ class is one of the AWT components•Java Foundation Classes JFC–Extension to Java in 1997–Has a collection of _______ components for enhanced GUIs–Swing component classes begin with ____5Java Applets•Applets are Java programs that can be _______________ in HTML documents–To run an applet you must create a _______ file which references the applet–Ready to Program also will run an applet•When browser loads Web page containing applet–Applet _____________ into Web browser–begins execution•Can be tested using _____________ program6Contrast Application with Applet Application Applet•Object class extended•Class ______ declared public•Has a main()•___________ keyword used•Uses System.exit(1)•JApplet class extended•class declared to be public•________() instead of main()•init() not declared with static keyword7Applet Declaration•Syntax (note difference from application declaration)public class ClassName extends JAapplet _____ __________ is an object that will be a subclass of JApplet8Body of an Applet•Note there is no ______________ method in an applet–JApplet class provides other methods instead of a main method•First method executed is the _______________ method9Applets•Applet–Program that runs in •appletviewer (test utility for applets)•Web browser (IE, Communicator)–Executes when HTML (________________________) document containing applet is opened–Applications run in command windows•Notes–Focus on fundamental programming concepts first•Explanations will come later10Applets and Web Pages – HTML •Applets embedded in a web page–Executed when web page loaded by browser•Web pages structured with HTML codes–HyperText Mark-up Language•Syntax<command> . . .</command>Turns format onTurns the format off11Applets and Web Pages – HTML•Embedding Java applets–Insert applet tags<APPLET></APPLET>•Call the specific applet by its __________<APPLET CODE = "Whatever.class" WIDTH = nnn HEIGHT = mmmm><\APPLET>Where nnn and mmm are specific _______ sizes12Applets and Web Pages – HTML•Create the web page code using a _______ editor•Save it with an .______ suffix•Open this file with appletviewer or with a _____ browser that supports Java•Java ________ must be installed (part of J2SDK 1.4.1 from Sun)<HTML><HEAD></HEAD><BODY><APPLET CODE = . . . ></APPLET></BODY></HTML>13Applets and Web Pages – HTML•Client Web browser anywhere can access this web page from its host server•Embedded Java applet runs on ________________ (of any type platform)•This means a client anywhere on any type of platform can run a piece of software developed on any other type of platformPlatform __________14Thinking About Objects•Java an object-oriented language–However, Java has constructs from structured programming•Object orientation–Natural way to think about world and writing computer programs•Object-oriented programming models the real world–_______________ - properties of objects•Size, shape, color, weight, etc.–_______________ - actions that objects can perform•A ball rolls, bounces, inflates and deflates15Thinking About Objects•Object orientation (continued)–_________________•New classes of objects absorb characteristics of existing classes–____________________•Objects usually do not know how other objects are implemented•We can drive cars without knowing how every part works internally16Thinking About ObjectsClass - unit of Java programming•Java focuses on _____________ (classes) –C focuses on verbs and is action oriented•Contain methods–Implement ___________________•Contain _________________–Implement attributes•Classes are reusable–Standardized, interchangeable parts17A Simple Java Applet: Drawing a String•Figure 3.6 – a welcome message applet•The .html code to run the applet in a browser•The program output shown in the Applet Viewer<html><applet code = "WelcomeApplet.class" width = "300" height = "45"></applet></html>18Running the Applet•Compile–Use Ready to Program –If no errors, bytecodes stored in WelcomeApplet.class•We must create an HTML file –Loads the applet into appletviewer or a browser–Ends in .htm or .html•To execute an applet–Create an HTML file indicating which applet the browser (or appletviewer) should load and execute19Running the Applet - Alternatively•Run from within Ready to Program•Prompt for applet window size appears•Applet window runs20import allows us to use ____________ classes (allowing us to use applets and graphics, in this case).extends allows us to inherit the capabilities of class JApplet.Method ___________ is guaranteed to be called in all applets. Its first line must be defined as above.21Running An Appletimport java.applet.Applet;import java.awt.Graphics;public class HelloApplet extends Applet {public void paint (Graphics g){g.drawString ("Hello. Welcome to",25,25);g.drawString ("Java Programming",25,40);}}import java.applet.Applet;import java.awt.Graphics;public class HelloApplet extends Applet {public void paint (Graphics g){g.drawString ("Hello. Welcome to",25,25);g.drawString ("Java Programming",25,40);}}• Enter this text into your Ready to Program editor• Compile the Java code22Running An Applet•Now create an .html file to run the applet•Save it as HelloApplet.html•Make sure you save it in the same directory as the .java file<html><applet code = "HelloApplet.class" width=275, height =


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?