tag within the tag in an HTML page, and accessed via the getParameter() method."> tag within the tag in an HTML page, and accessed via the getParameter() method."> Address: [go: up one dir, main page] Include Form Remove Scripts Session Cookies Open navigation menuClose suggestionsSearchSearchenChange LanguageUploadSign inSign inDownload free for days0 ratings0% found this document useful (0 votes)51 views20 pagesUnit 1This document provides information about Java applets including: 1. Applets are small Java applications that can be accessed on web servers and run within web pages. They extend the Applet class and do not have a main method. 2. Applets have a lifecycle consisting of init(), start(), paint(), stop(), and destroy() methods that are automatically called during execution. 3. Parameters can be passed to applets using the <param> tag within the <applet> tag in an HTML page, and accessed via the getParameter() method.Uploaded bygoraniya reenaAI-enhanced title and descriptionCopyright© © All Rights ReservedWe take content rights seriously. If you suspect this is your content, claim it here.Available FormatsDownload as PDF, TXT or read online on ScribdDownloadSaveSave Unit-1 For Later0%0% found this document useful, undefined0%, undefinedEmbedSharePrintReport0 ratings0% found this document useful (0 votes)51 views20 pagesUnit 1This document provides information about Java applets including: 1. Applets are small Java applications that can be accessed on web servers and run within web pages. They extend the Applet class and do not have a main method. 2. Applets have a lifecycle consisting of init(), start(), paint(), stop(), and destroy() methods that are automatically called during execution. 3. Parameters can be passed to applets using the <param> tag within the <applet> tag in an HTML page, and accessed via the getParameter() method.Uploaded bygoraniya reenaAI-enhanced title and descriptionCopyright© © All Rights ReservedWe take content rights seriously. If you suspect this is your content, claim it here.Available FormatsDownload as PDF, TXT or read online on ScribdCarousel PreviousCarousel NextDownloadSaveSave Unit-1 For Later0%0% found this document useful, undefined0%, undefinedEmbedSharePrintReportDownload nowDownloadYou are on page 1/ 20SearchFullscreenUNIT-1Java Applets Applet• Small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document.• Extends the java.applet.Applet class.• Does not have any main() method.• Viewed using JVM. Applet• To run the applet: – Plug-in of the Web browser. – Separate runtime environment (appletviewer).• Designed to be embedded within an HTML page.• When a user views an HTML page that contains an applet, the code for the applet is downloaded to the user's machine. Applet v/s Application Applet ApplicationIt requires some third party tool like a It called as stand-alone application asbrowser to execute. application can be executed from command prompt.In applet main() method is not present. In application main() method is present.It cannot access anything on the system It can access any data or softwareexcept browser’s services. available on the system.It requires highest security for the system It does not require any security.as they are untrusted.Applet starts execution after init() Applications start execution after main()method. method.Security Manager provided by Browser. No default Security Manager. All code isRemote code is untrusted. trusted by default.Lifecycle controlled by Browser. Lifecycle controlled by JRE. Local Applet v/s Remote Applet Local Applet Remote AppletIt is developed and stored in local system. It is developed and stored on remote system.The web page will search the local system The web page will require an internetdirectories, find the local applet and connection to locate and load the remoteexecute it. applet from the remote computer.Execution of local applet does not require Execution of remote applet must requireinternet connection. internet connection.Example: Example:<applet codebase="path" <applet codebase="URL "code="xyz.class" width=120 height=120 > code="xyz.class" width=120 height=120 ></applet> </applet>path = Path of an applet on local system. URL = Url at which applet is located.Applet Life Cycle Applet Life Cycle• 5 stages: – init(), start(), paint(), stop(), destroy()• Methods called automatically whenever required for the execution of the applet.• Methods are defined in java.applet.Applet class except paint() method.• paint() is defined in java.awt.Component class. Applet Life Cycle• init(): – Used to initialize the Applet. – Invoked only once. – Called before all the other methods.• start(): – Automatically called after the browser call the init method. – Also called whenever the user returns to the page containing the applet. – Can be called repeatedly in the same applet. Applet Life Cycle• stop(): – Called when an applet comes in idle state either implicitly or explicitly. – Implicitly stopped when we leave the page containing the currently running applet. – Explicitly stopped when we call stop() method to stop its execution. – Can be called repeatedly in the same applet. Applet Life Cycle• destroy(): – Called when the browser shuts down normally. – Called only once. – Called just before an applet object is removed from the memory. Applet Life Cycle• paint(): – Invoked immediately after the start() method. – Also, any time the applet needs to repaint itself. – Provides Graphics class object that can be used for drawing oval, rectangle etc. Applet Life Cycle Exampleimport java.awt.*;import java.applet.*;public class AppletMethods extends Applet{ String msg; public void init() { msg = "Inside init method ----"; } public void start() { msg += " Inside start method ---"; } Applet Life Cycle Example public void paint(Graphics g) { showStatus(“Painting”); g.drawString(msg, 20, 10); } public void stop() { msg += "Inside stop method ----"; } public void destroy() { msg += "Inside destroy method ----"; }} Run an Applet• Two ways to run an applet : – Using HTML file. – Using AppletViewer tool. Using HTML File// Demo.java //Applet.htmlimport java.applet.Applet; <html>import java.awt.Graphics; <body>public class Demo extends Applet <applet code="Demo.class"{ width="300" height="300"> public void paint(Graphics g) </applet> { </body> g.drawString("welcome",200,200); </html> }} Using Appletviewer Tool// Demo.javaimport java.applet.Applet;import java.awt.Graphics;/*<applet code="Demo.class" width="300" height="300"></applet>*/public class Demo extends Applet{ public void paint(Graphics g) On Command Prompt: { > javac Demo.java g.drawString("welcome",200,200); > appletviewer Demo.java }} Other Applet MethodsMethod Descriptionvoid setBackground (Color colorname) Set Background of an applet.void setForeground (Color colorname) Set Foreground of an applet.void showStatus (String str) To display status message in the status bar.URL getDocumentBase() Returns the URL of the HTML document that invokes the applet.URL getCodeBase() Returns the URL associated with the invoking applet.String getAppletInfo( ) Returns a string that describes the applet.void resize(int width, int height) Resizes the applet according to the dimensions specified by width and height. Applet Tag• Used for embedding a Java applet within an HTML document.• Syntax: (Attribute in square brackets are optional.) < APPLET [CODEBASE = codebaseURL] CODE = appletFile [ALT = alternateText] [NAME = appletInstanceName] WIDTH = pixels HEIGHT = pixels [ALIGN = alignment] [VSPACE = pixels] [HSPACE = pixels] > [< PARAM NAME = AttributeName VALUE = AttributeValue>] [< PARAM NAME = AttributeName2 VALUE = AttributeValue>] . . . [HTML Displayed in the absence of Java] </APPLET> Applet Tag AttributesAttribute Value DescriptionCODEBASE url URL of the directory or folder that contains the applet code.CODE .Class file Name of the file that contains the applet's compiled Applet subclass.ALT alternateText It specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets.NAME appletInstance It specifies a name for the applet instance, which makes it possible for Name applets on the same page to find (and communicate with) each other.WIDTH pixels It givea the initial width (in pixels) of the applet display area.HEIGHT pixels It give a the initial height (in pixels) of the applet display area.ALIGN alignment It specifies the alignment of the applet.VSPACE pixels It specifies the number of pixels above and below the appletHSPACE pixels It specifies the number of pixels on each side of the appletPARAM Attribute Name The PARAM tag allows you to specify applet-specific arguments in anNAME and and Value HTML page. Applets access their attributes with the getParameter( )VALUE method. Passing Parameters to Applet//AppletParameter.java //AppletParameter.html <HTML>import java.applet.*; <HEAD>import java.awt.*; <TITLE> Java Applet Example</TITLE>public class AppletParameter extends Applet{ </HEAD> public String myString; <BODY> public void init() <APPLET CODE = { "AppletParameter.class" myString = getParameter("Hello"); WIDTH="400" HEIGHT="50"> } <PARAM NAME="Hello" VALUE="Hello, public void paint(Graphics g) Welcome to Java World :)" > { g.setColor(Color.red); </APPLET> g.drawString(myString, 20, 20); </BODY> } </HTML>}You might also likeApplet Programming: Unit 1PDFNo ratings yetApplet Programming: Unit 110 pages4 1 AppletPDFNo ratings yet4 1 Applet31 pagesApplet NewPDFNo ratings yetApplet New62 pagesOops - Java Unit 5 NotesPDFNo ratings yetOops - Java Unit 5 Notes37 pages27 Appletprogramming 130815152759 Phpapp01PDFNo ratings yet27 Appletprogramming 130815152759 Phpapp0131 pagesChapter 5PDFNo ratings yetChapter 531 pagesOop Java Unit 5PDFNo ratings yetOop Java Unit 5325 pagesApplet Programming Java PDFNo ratings yetApplet Programming Java 22 pagesApplets: Applet Programs Application ProgramsPDFNo ratings yetApplets: Applet Programs Application Programs21 pagesAppletsPDFNo ratings yetApplets29 pagesUNIT-I AppletPDFNo ratings yetUNIT-I Applet11 pagesUnit-5 Java Applets & Graphics Programming (20 Marks)PDFNo ratings yetUnit-5 Java Applets & Graphics Programming (20 Marks)96 pagesJava Applets and Graphics Programming: 10 MarksPDFNo ratings yetJava Applets and Graphics Programming: 10 Marks28 pagesUnit 6PDFNo ratings yetUnit 67 pagesAppletsPDFNo ratings yetApplets19 pagesIntroduction To AppletPDFNo ratings yetIntroduction To Applet4 pagesAPPLET PROGRAMMING and GRAPHICSPDFNo ratings yetAPPLET PROGRAMMING and GRAPHICS45 pagesJava Unit-5PDFNo ratings yetJava Unit-535 pagesJava AppletPDFNo ratings yetJava Applet26 pagesAdvanced Java Lecture-6PDFNo ratings yetAdvanced Java Lecture-639 pagesCH5 JPRPDFNo ratings yetCH5 JPR55 pagesUnit 6 JavaPDFNo ratings yetUnit 6 Java62 pagesApplet&JAppletPDFNo ratings yetApplet&JApplet10 pagesApplet ProgrammingPDFNo ratings yetApplet Programming63 pagesWa0064.PDFNo ratings yetWa0064.17 pagesModule 4.docxPDFNo ratings yetModule 4.docx25 pagesAppletPDFNo ratings yetApplet48 pagesEvent HandlingPDFNo ratings yetEvent Handling64 pagesJava Unit-V NotesPDFNo ratings yetJava Unit-V Notes18 pagesModern Programming Tools and Techniques-I: Lovely Professional University, PunjabPDFNo ratings yetModern Programming Tools and Techniques-I: Lovely Professional University, Punjab44 pagesEContent 11 2024 09 22 22 46 48 Unit1 JavaAppletspptx 2024 07 25 09 14 11PDFNo ratings yetEContent 11 2024 09 22 22 46 48 Unit1 JavaAppletspptx 2024 07 25 09 14 1143 pagesJava Unit4 AppletProgrammingPDFNo ratings yetJava Unit4 AppletProgramming6 pagesUnit No.1PDFNo ratings yetUnit No.131 pagesAdvanve Java BookPDFNo ratings yetAdvanve Java Book296 pagesApplets in JavaPDFNo ratings yetApplets in Java13 pagesAppletPDFNo ratings yetApplet24 pagesJava Chap3PDFNo ratings yetJava Chap325 pagesApplet JAVA Update2PDFNo ratings yetApplet JAVA Update264 pagesApplet 1PDFNo ratings yetApplet 160 pagesOOPJ UNIT - 5 EcePDFNo ratings yetOOPJ UNIT - 5 Ece84 pages320243-Unit No.5-JPRPDFNo ratings yet320243-Unit No.5-JPR32 pagesCJT 11-Applets and Advanced Graphics-6X1PDFNo ratings yetCJT 11-Applets and Advanced Graphics-6X114 pagesUnit No.1PDFNo ratings yetUnit No.134 pagesUnit 6.1PDFNo ratings yetUnit 6.123 pagesJava AppletPDFNo ratings yetJava Applet38 pagesAppletPDFNo ratings yetApplet27 pagesApplet ProgrammingPDFNo ratings yetApplet Programming12 pagesUnit - 4PDFNo ratings yetUnit - 438 pagesUnit IPDFNo ratings yetUnit I11 pagesApplet ProgrammingPDFNo ratings yetApplet Programming27 pagesApple TsPDFNo ratings yetApple Ts16 pagesUnit - 5 (3) 69PDFNo ratings yetUnit - 5 (3) 6917 pagesAppletsPDFNo ratings yetApplets11 pagesOopr212 Prelims ReviewerPDFNo ratings yetOopr212 Prelims Reviewer13 pagesJAVA Unit 6PDFNo ratings yetJAVA Unit 648 pagesUnit 5 - AppletPDFNo ratings yetUnit 5 - Applet24 pagesApplet-HTML Programming2018PDFNo ratings yetApplet-HTML Programming201866 pagesApplet Unit IIPDFNo ratings yetApplet Unit II20 pagesCore Java Programming BookFrom EverandCore Java Programming BookManish SoniNo ratings yetAngular Portfolio App Development: Create your personal brandFrom EverandAngular Portfolio App Development: Create your personal brandAbdelfattah RagabNo ratings yetDLL Lessonlog - DRR Week 3PDFNo ratings yetDLL Lessonlog - DRR Week 36 pagesPERT-CPM in Travel MedicinePDFNo ratings yetPERT-CPM in Travel Medicine2 pagesBook 5 - Unit 3PDFNo ratings yetBook 5 - Unit 312 pagesDell Case Analysis Presentation Rev 3PDFNo ratings yetDell Case Analysis Presentation Rev 335 pagesBJ Wadia ReportPDFNo ratings yetBJ Wadia Report31 pagesOdes 800cc1000cc - WorkshopPDFNo ratings yetOdes 800cc1000cc - Workshop131 pagesTheory of Relational InferencePDFNo ratings yetTheory of Relational Inference46 pagesSteps To Writing An Argumentative Research Paper 2PDFNo ratings yetSteps To Writing An Argumentative Research Paper 22 pages24 Bodaq E-Catalog LowPDFNo ratings yet24 Bodaq E-Catalog Low62 pagesDevelopment of HPLC Method For The Determination of Zinc Carnosine in Bulk and Dosage FormsPDFNo ratings yetDevelopment of HPLC Method For The Determination of Zinc Carnosine in Bulk and Dosage Forms5 pages50 of The WorldPDF0% (1)50 of The World50 pagesCreate Apply StylesPDFNo ratings yetCreate Apply Styles4 pagesSurety Bond Insurance Retail Policy WordingsPDFNo ratings yetSurety Bond Insurance Retail Policy Wordings16 pages6WBS0011-0609-2019 - Contemporary Issues in Business and Management (SDL) - CompressedPDFNo ratings yet6WBS0011-0609-2019 - Contemporary Issues in Business and Management (SDL) - Compressed3 pagesDelamination in Wood Wood Products and Wood-Based CompositesPDFNo ratings yetDelamination in Wood Wood Products and Wood-Based Composites416 pagesBangla News SummarizationPDFNo ratings yetBangla News Summarization10 pages06mindset1 ExtraListenPrac6PDFNo ratings yet06mindset1 ExtraListenPrac61 pageWhether Application For Android OPERATING SYSTEM MADPDFNo ratings yetWhether Application For Android OPERATING SYSTEM MAD13 pagesPhrasal Verbs RevisionPDFNo ratings yetPhrasal Verbs Revision9 pagesGoldfish: by Dick MillsPDFNo ratings yetGoldfish: by Dick Mills7 pagesSci Judgement On Arnab GoswamiPDFNo ratings yetSci Judgement On Arnab Goswami55 pagesDhaunka STPRPDFNo ratings yetDhaunka STPR124 pagesBikki Sainath TermpaperPDFNo ratings yetBikki Sainath Termpaper10 pagesNaitik Admit CardPDFNo ratings yetNaitik Admit Card3 pagesMason's RulePDF100% (1)Mason's Rule1 pagePatent TrollPDFNo ratings yetPatent Troll12 pagesEthics of Belief Sample SyllabusPDFNo ratings yetEthics of Belief Sample Syllabus2 pagesPWD Ramp AroundPDFNo ratings yetPWD Ramp Around3 pagesRelocation and Redevelopment of Municipal Hall PDFNo ratings yetRelocation and Redevelopment of Municipal Hall 10 pagesProgram To Add Two 32 Bit Numbers - ProjectsGeekPDFNo ratings yetProgram To Add Two 32 Bit Numbers - ProjectsGeek8 pagesDocumentsComputersInternet & Web
Unit 1
AI-enhanced title and description
Java Applets Applet• Small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document.• Extends the java.applet.Applet class.• Does not have any main() method.• Viewed using JVM. Applet• To run the applet: – Plug-in of the Web browser. – Separate runtime environment (appletviewer).• Designed to be embedded within an HTML page.• When a user views an HTML page that contains an applet, the code for the applet is downloaded to the user's machine. Applet v/s Application Applet ApplicationIt requires some third party tool like a It called as stand-alone application asbrowser to execute. application can be executed from command prompt.In applet main() method is not present. In application main() method is present.It cannot access anything on the system It can access any data or softwareexcept browser’s services. available on the system.It requires highest security for the system It does not require any security.as they are untrusted.Applet starts execution after init() Applications start execution after main()method. method.Security Manager provided by Browser. No default Security Manager. All code isRemote code is untrusted. trusted by default.Lifecycle controlled by Browser. Lifecycle controlled by JRE. Local Applet v/s Remote Applet Local Applet Remote AppletIt is developed and stored in local system. It is developed and stored on remote system.The web page will search the local system The web page will require an internetdirectories, find the local applet and connection to locate and load the remoteexecute it. applet from the remote computer.Execution of local applet does not require Execution of remote applet must requireinternet connection. internet connection.Example: Example:<applet codebase="path" <applet codebase="URL "code="xyz.class" width=120 height=120 > code="xyz.class" width=120 height=120 ></applet> </applet>path = Path of an applet on local system. URL = Url at which applet is located.Applet Life Cycle Applet Life Cycle• 5 stages: – init(), start(), paint(), stop(), destroy()• Methods called automatically whenever required for the execution of the applet.• Methods are defined in java.applet.Applet class except paint() method.• paint() is defined in java.awt.Component class. Applet Life Cycle• init(): – Used to initialize the Applet. – Invoked only once. – Called before all the other methods.• start(): – Automatically called after the browser call the init method. – Also called whenever the user returns to the page containing the applet. – Can be called repeatedly in the same applet. Applet Life Cycle• stop(): – Called when an applet comes in idle state either implicitly or explicitly. – Implicitly stopped when we leave the page containing the currently running applet. – Explicitly stopped when we call stop() method to stop its execution. – Can be called repeatedly in the same applet. Applet Life Cycle• destroy(): – Called when the browser shuts down normally. – Called only once. – Called just before an applet object is removed from the memory. Applet Life Cycle• paint(): – Invoked immediately after the start() method. – Also, any time the applet needs to repaint itself. – Provides Graphics class object that can be used for drawing oval, rectangle etc. Applet Life Cycle Exampleimport java.awt.*;import java.applet.*;public class AppletMethods extends Applet{ String msg; public void init() { msg = "Inside init method ----"; } public void start() { msg += " Inside start method ---"; } Applet Life Cycle Example public void paint(Graphics g) { showStatus(“Painting”); g.drawString(msg, 20, 10); } public void stop() { msg += "Inside stop method ----"; } public void destroy() { msg += "Inside destroy method ----"; }} Run an Applet• Two ways to run an applet : – Using HTML file. – Using AppletViewer tool. Using HTML File// Demo.java //Applet.htmlimport java.applet.Applet; <html>import java.awt.Graphics; <body>public class Demo extends Applet <applet code="Demo.class"{ width="300" height="300"> public void paint(Graphics g) </applet> { </body> g.drawString("welcome",200,200); </html> }} Using Appletviewer Tool// Demo.javaimport java.applet.Applet;import java.awt.Graphics;/*<applet code="Demo.class" width="300" height="300"></applet>*/public class Demo extends Applet{ public void paint(Graphics g) On Command Prompt: { > javac Demo.java g.drawString("welcome",200,200); > appletviewer Demo.java }} Other Applet MethodsMethod Descriptionvoid setBackground (Color colorname) Set Background of an applet.void setForeground (Color colorname) Set Foreground of an applet.void showStatus (String str) To display status message in the status bar.URL getDocumentBase() Returns the URL of the HTML document that invokes the applet.URL getCodeBase() Returns the URL associated with the invoking applet.String getAppletInfo( ) Returns a string that describes the applet.void resize(int width, int height) Resizes the applet according to the dimensions specified by width and height. Applet Tag• Used for embedding a Java applet within an HTML document.• Syntax: (Attribute in square brackets are optional.) < APPLET [CODEBASE = codebaseURL] CODE = appletFile [ALT = alternateText] [NAME = appletInstanceName] WIDTH = pixels HEIGHT = pixels [ALIGN = alignment] [VSPACE = pixels] [HSPACE = pixels] > [< PARAM NAME = AttributeName VALUE = AttributeValue>] [< PARAM NAME = AttributeName2 VALUE = AttributeValue>] . . . [HTML Displayed in the absence of Java] </APPLET> Applet Tag AttributesAttribute Value DescriptionCODEBASE url URL of the directory or folder that contains the applet code.CODE .Class file Name of the file that contains the applet's compiled Applet subclass.ALT alternateText It specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets.NAME appletInstance It specifies a name for the applet instance, which makes it possible for Name applets on the same page to find (and communicate with) each other.WIDTH pixels It givea the initial width (in pixels) of the applet display area.HEIGHT pixels It give a the initial height (in pixels) of the applet display area.ALIGN alignment It specifies the alignment of the applet.VSPACE pixels It specifies the number of pixels above and below the appletHSPACE pixels It specifies the number of pixels on each side of the appletPARAM Attribute Name The PARAM tag allows you to specify applet-specific arguments in anNAME and and Value HTML page. Applets access their attributes with the getParameter( )VALUE method. Passing Parameters to Applet//AppletParameter.java //AppletParameter.html <HTML>import java.applet.*; <HEAD>import java.awt.*; <TITLE> Java Applet Example</TITLE>public class AppletParameter extends Applet{ </HEAD> public String myString; <BODY> public void init() <APPLET CODE = { "AppletParameter.class" myString = getParameter("Hello"); WIDTH="400" HEIGHT="50"> } <PARAM NAME="Hello" VALUE="Hello, public void paint(Graphics g) Welcome to Java World :)" > { g.setColor(Color.red); </APPLET> g.drawString(myString, 20, 20); </BODY> } </HTML>}