This document provides an overview of applets, including:
- Applets are Java programs that run within web browsers. Examples include interactive scientific visualizations and real-time satellite trackers.
- Applets have a lifecycle controlled by the browser via init(), start(), stop(), and destroy() methods. They are also subject to security restrictions since they are downloaded from the web.
- Resources like images, audio, and text files can be accessed from the home server hosting the applet. Communication between the applet and browser is also possible using the AppletContext interface.
This document discusses Java applets, including their life cycle, differences from Swing, and advantages/disadvantages. Applets run in a web browser and have an initialization state, running state, idle/stopped state, and dead state. They do not use a main method but instead override init(), start(), paint(), stop(), and destroy() methods. Compared to Swing, applets are heavier weight, use AWT layouts, and require a browser to run. Advantages include cross-platform capability and moving work to the client, while disadvantages are needing the Java plugin and some browsers not supporting applets.
This document provides an overview of Java applets, including:
- Applets are Java programs that run in a web browser and are typically embedded in web pages. They must extend the Applet class.
- There are two types of applets - AWT applets which use older GUI classes, and Swing applets which use newer GUI classes.
- The Applet class provides lifecycle methods like init(), start(), stop(), and destroy() that are called at different points in the applet's execution. It also includes painting and display methods like paint(), repaint(), and drawString().
This document provides an overview of Applets and Java GUI programming. It discusses Applets, their life cycle, how to run Applets using AppletViewer and HTML, and classes used in Applet programming like Applet, Graphics, Color, Font, and AWT components. It also covers Swing components like JApplet, JComponent, JLabel, JTextField, JButton, and JRadioButton. Code examples and demonstrations are provided for many of the concepts discussed.
Java applets are small Java programs that can be embedded within HTML pages. When a user views a page containing an applet, the applet code is transferred to their system and executed by the Java Virtual Machine within their browser. Applets allow for interactive features on web pages like capturing mouse input and including buttons or checkboxes. They can also play media formats not natively supported by browsers. Applets are embedded using the applet or object tags, which can specify the applet's location and download any necessary Java plugins.
introduction to Applets, life cycle of applets, methods of applets, examples,embedding apllets in html files, compiling and running of applets with appletviewer
The life cycle of an applet involves different states including born, running, idle, and dead as it loads, executes code, becomes inactive, and is removed from memory. An applet transitions between these states, calling methods like init(), start(), stop(), paint(), and destroy() that perform initialization, launching execution, pausing, drawing to the screen, and cleanup. The init() method is called once while start() and stop() can be called multiple times as the applet loads, resumes running, and becomes inactive.
This document provides information about applets including:
- Applets are small programs that can be embedded in web pages and run within web browsers. They allow for dynamic and interactive content.
- There are two types of applets: local applets stored on the local system and remote applets stored on remote servers.
- The lifecycle of a Java applet involves init(), start(), stop(), destroy(), and paint() methods being called in a specific order when the applet loads and runs in the browser.
This document provides an overview of Java applets, including:
- A Java applet is a small Java application delivered as bytecode and run within a Java Virtual Machine in the user's web browser.
- Applets are typically embedded in web pages and can display interactive elements like buttons and text boxes.
- The document discusses the lifecycle methods of applets like init(), start(), stop(), and destroy(), and provides simple code examples of basic "Hello World" applets.
This document discusses Java applets, including their life cycle, differences from Swing, and advantages/disadvantages. Applets run in a web browser and have an initialization state, running state, idle/stopped state, and dead state. They do not use a main method but instead override init(), start(), paint(), stop(), and destroy() methods. Compared to Swing, applets are heavier weight, use AWT layouts, and require a browser to run. Advantages include cross-platform capability and moving work to the client, while disadvantages are needing the Java plugin and some browsers not supporting applets.
This document provides an overview of Java applets, including:
- Applets are Java programs that run in a web browser and are typically embedded in web pages. They must extend the Applet class.
- There are two types of applets - AWT applets which use older GUI classes, and Swing applets which use newer GUI classes.
- The Applet class provides lifecycle methods like init(), start(), stop(), and destroy() that are called at different points in the applet's execution. It also includes painting and display methods like paint(), repaint(), and drawString().
This document provides an overview of Applets and Java GUI programming. It discusses Applets, their life cycle, how to run Applets using AppletViewer and HTML, and classes used in Applet programming like Applet, Graphics, Color, Font, and AWT components. It also covers Swing components like JApplet, JComponent, JLabel, JTextField, JButton, and JRadioButton. Code examples and demonstrations are provided for many of the concepts discussed.
Java applets are small Java programs that can be embedded within HTML pages. When a user views a page containing an applet, the applet code is transferred to their system and executed by the Java Virtual Machine within their browser. Applets allow for interactive features on web pages like capturing mouse input and including buttons or checkboxes. They can also play media formats not natively supported by browsers. Applets are embedded using the applet or object tags, which can specify the applet's location and download any necessary Java plugins.
introduction to Applets, life cycle of applets, methods of applets, examples,embedding apllets in html files, compiling and running of applets with appletviewer
The life cycle of an applet involves different states including born, running, idle, and dead as it loads, executes code, becomes inactive, and is removed from memory. An applet transitions between these states, calling methods like init(), start(), stop(), paint(), and destroy() that perform initialization, launching execution, pausing, drawing to the screen, and cleanup. The init() method is called once while start() and stop() can be called multiple times as the applet loads, resumes running, and becomes inactive.
This document provides information about applets including:
- Applets are small programs that can be embedded in web pages and run within web browsers. They allow for dynamic and interactive content.
- There are two types of applets: local applets stored on the local system and remote applets stored on remote servers.
- The lifecycle of a Java applet involves init(), start(), stop(), destroy(), and paint() methods being called in a specific order when the applet loads and runs in the browser.
This document provides an overview of Java applets, including:
- A Java applet is a small Java application delivered as bytecode and run within a Java Virtual Machine in the user's web browser.
- Applets are typically embedded in web pages and can display interactive elements like buttons and text boxes.
- The document discusses the lifecycle methods of applets like init(), start(), stop(), and destroy(), and provides simple code examples of basic "Hello World" applets.
Applets are small Java programs that run in web browsers. They have a lifecycle with methods like init(), start(), paint(), stop(), and destroy() that get called at different points. The init() method initializes variables, start() runs when the applet is displayed, paint() redraws the output, stop() runs when the browser closes, and destroy() removes the applet from memory. Sample code shows an applet class that extends Applet and overrides these methods to track calls and draw status messages. The status window can also be used to display messages to users.
This document provides an overview of Java applets, including:
- An applet is a Java program that runs in a web browser and has full access to the Java API.
- The main differences from a standalone application are that an applet extends Applet, does not define a main method, and is designed to run embedded in an HTML page.
- When a user views an HTML page containing an applet, the applet code is downloaded and a JVM instance is created to run the applet.
- "Hello World" is a simple example applet that draws a string to the screen in its paint method.
Java applets allow Java programs to run in a web browser. Applets are downloaded and run similarly to web pages. When a web page containing an applet tag is loaded, the browser downloads the applet class file from the web server and executes it within the browser's context on the client host. Applets are subject to security restrictions that prevent them from accessing local files or making network connections except back to the host from which they were downloaded.
The document discusses applet classes, methods, and architecture. It explains that applet is a subclass of Panel and Component classes, and provides methods for running applets. The document also describes how applets are event-driven programs that wait for and respond to user interactions like mouse clicks or key presses by calling event handlers.
This document provides information about applet programming in Java. It discusses that applets are small Java programs used primarily for internet computing. Applets can perform tasks like displaying graphics, playing sounds, and accepting user input. Key differences between applets and standalone applications include applets not having a main method, needing to be embedded in an HTML page, and having restrictions on file/network access. The document also covers the applet lifecycle, writing applet code, and using HTML tags to embed applets in web pages.
- Applets are small Java applications that run within web browsers. They are embedded in HTML pages and can interact with the user.
- Applets follow an event-driven model where the AWT notifies the applet of user interactions. The applet then takes action and returns control to the AWT.
- The applet lifecycle includes init(), start(), stop(), and destroy() methods that are called at different points as the applet loads and runs within the browser.
This document provides an overview of Java applets, including:
- Java programs are divided into applications and applets, with applets running across the internet to make web pages dynamic.
- Applets override lifecycle methods like init(), start(), stop(), and destroy() and are run by web browsers with Java plugins.
- Creation of applets involves extending the Applet class, overriding methods, compiling, and embedding in an HTML file.
- Pros of applets include faster response time and security, while a con is requiring browser plugins.
- A sample applet draws a string using the paint() method, and this can be run from an HTML file or the applet viewer tool.
The document discusses applet initialization and termination. When an applet begins, the methods init(), start(), and paint() are called in that order. When an applet terminates, the methods stop() and destroy() are called, with stop() always being called before destroy(). The init() method initializes variables and is only called once, while start() resumes execution when the user returns to the page and paint() repairs damage when the applet regains focus.
An applet is a Java program that runs in a web browser. Applets extend the Applet class and have a lifecycle of init(), start(), stop(), and destroy() methods. Applets are embedded in HTML pages and have security restrictions enforced by the browser. When a user views an HTML page containing an applet, the applet code is downloaded and a JVM instance is created to run the applet.
This document provides an overview of applet programming in Java. It discusses what applets are, how they are executed, their lifecycle methods, and how to pass parameters to applets. It also covers how to request repainting of an applet window, use the status window, and transfer control to other URLs using the AppletContext interface and showDocument method. Key aspects of the APPLET tag for embedding applets in HTML are also explained.
An applet is a Java program that runs in a web browser. Applets allow interactive components and enhancements to be added to webpages. Advantages include faster response times since applets run on the client-side, security, and platform independence. The main methods in an applet's lifecycle are init(), start(), stop(), and destroy(). Drawbacks include requiring the Java plugin to be installed in the client's browser.
An applet is a small Java program that can run in a web browser. It is embedded in an HTML page and downloaded from a server to run on a client computer. Applets have a lifecycle of initialization, startup, running, idle, and destruction. They allow for interactive graphics and animations to be added to webpages but have security restrictions around accessing files and making network connections.
This document provides an overview of Java applets and introduces some simple example applets. It discusses how applets differ from applications in that they are designed to run within a web browser or applet viewer. It then presents two simple applets - one that draws a single string and another that draws two lines of text. The document demonstrates how to create, compile, and run a basic "Hello World" style applet and provides the code and explanation for both applets. It also references chapters in the text that will provide more in-depth explanations of applet and Java concepts.
The document discusses applet programming in Java. It defines an applet as an interactive panel embedded in a web page that can be run from a browser. Applets have a life cycle of init(), start(), stop(), and destroy() methods. The paint() method is used for any drawing or painting beyond standard GUI components. Repaint() requests a repaint but does not guarantee it. Example code demonstrates basic graphics methods and includes an applet example with supporting HTML. Advantages of applets include cross-platform capability and security sandboxing, while disadvantages are needing the Java plugin and slower initial startup.
Java Applet Basics, Important points, Life cycle of an applet, AWT, AWT HIERARCHY, Creating Frame by extending Frame class, Creating Frame by creating instance of Frame class, Java Exceptions, Java try and catch, Syntax, Example for try and catch,
This document discusses the applet skeleton in Java. It explains that applets override lifecycle methods like init(), start(), stop(), and destroy() to control their execution states. These methods are defined in the Applet class. It provides a code example of an applet skeleton that implements these methods, as well as the paint() method defined in the Component class. When run, this skeleton applet generates a window to display itself.
An applet is a Java program that runs in a web browser. It extends the Applet class and does not define a main method. Applets are embedded in HTML pages and have a lifecycle of init(), start(), stop(), and destroy() methods. They can use the Graphics class to draw shapes, text, and images. Parameters can be passed to applets from the HTML code.
This document provides an introduction and overview of Java applet programming. It discusses what Java and applets are, the applet skeleton structure including common lifecycle methods like init(), start(), paint(), stop(), and destroy(). It also outlines the steps to write an applet code, compile it, and include it in an HTML file using applet tags to display the applet. An example Java applet class and HTML code is provided at the end to demonstrate a simple "Hello World" style applet.
The document discusses applet programming in Java. It defines an applet as a special type of Java program that runs in a web browser. There are two types of applets: local applets that run on the local machine, and remote applets that run on a web server. The document outlines the applet lifecycle and methods, how applets differ from other applications, the steps to develop an applet, and how to run an applet using an HTML file or the applet viewer tool.
This document provides an overview of GUI programming basics using the AWT API in Java. It discusses the key component, container and layout manager classes used to create graphical user interfaces in Java. Component classes like Button, Label and TextField are used to add interactive elements, while container classes like Frame and Panel hold other components. Layout managers help position and organize components visually. The document also provides examples of creating simple frames and applications using these AWT classes.
This document provides an overview of applet components in Java, including labels, buttons, checkboxes, choice controls, lists, scroll bars, text fields, text areas, menus, and containers. It also covers layout managers like FlowLayout, GridLayout, and BorderLayout which position components within containers. Finally, it discusses event handling using the event delegation model where sources generate events that are handled by listener interfaces like ActionListener.
Applets are small Java programs that run in web browsers. They have a lifecycle with methods like init(), start(), paint(), stop(), and destroy() that get called at different points. The init() method initializes variables, start() runs when the applet is displayed, paint() redraws the output, stop() runs when the browser closes, and destroy() removes the applet from memory. Sample code shows an applet class that extends Applet and overrides these methods to track calls and draw status messages. The status window can also be used to display messages to users.
This document provides an overview of Java applets, including:
- An applet is a Java program that runs in a web browser and has full access to the Java API.
- The main differences from a standalone application are that an applet extends Applet, does not define a main method, and is designed to run embedded in an HTML page.
- When a user views an HTML page containing an applet, the applet code is downloaded and a JVM instance is created to run the applet.
- "Hello World" is a simple example applet that draws a string to the screen in its paint method.
Java applets allow Java programs to run in a web browser. Applets are downloaded and run similarly to web pages. When a web page containing an applet tag is loaded, the browser downloads the applet class file from the web server and executes it within the browser's context on the client host. Applets are subject to security restrictions that prevent them from accessing local files or making network connections except back to the host from which they were downloaded.
The document discusses applet classes, methods, and architecture. It explains that applet is a subclass of Panel and Component classes, and provides methods for running applets. The document also describes how applets are event-driven programs that wait for and respond to user interactions like mouse clicks or key presses by calling event handlers.
This document provides information about applet programming in Java. It discusses that applets are small Java programs used primarily for internet computing. Applets can perform tasks like displaying graphics, playing sounds, and accepting user input. Key differences between applets and standalone applications include applets not having a main method, needing to be embedded in an HTML page, and having restrictions on file/network access. The document also covers the applet lifecycle, writing applet code, and using HTML tags to embed applets in web pages.
- Applets are small Java applications that run within web browsers. They are embedded in HTML pages and can interact with the user.
- Applets follow an event-driven model where the AWT notifies the applet of user interactions. The applet then takes action and returns control to the AWT.
- The applet lifecycle includes init(), start(), stop(), and destroy() methods that are called at different points as the applet loads and runs within the browser.
This document provides an overview of Java applets, including:
- Java programs are divided into applications and applets, with applets running across the internet to make web pages dynamic.
- Applets override lifecycle methods like init(), start(), stop(), and destroy() and are run by web browsers with Java plugins.
- Creation of applets involves extending the Applet class, overriding methods, compiling, and embedding in an HTML file.
- Pros of applets include faster response time and security, while a con is requiring browser plugins.
- A sample applet draws a string using the paint() method, and this can be run from an HTML file or the applet viewer tool.
The document discusses applet initialization and termination. When an applet begins, the methods init(), start(), and paint() are called in that order. When an applet terminates, the methods stop() and destroy() are called, with stop() always being called before destroy(). The init() method initializes variables and is only called once, while start() resumes execution when the user returns to the page and paint() repairs damage when the applet regains focus.
An applet is a Java program that runs in a web browser. Applets extend the Applet class and have a lifecycle of init(), start(), stop(), and destroy() methods. Applets are embedded in HTML pages and have security restrictions enforced by the browser. When a user views an HTML page containing an applet, the applet code is downloaded and a JVM instance is created to run the applet.
This document provides an overview of applet programming in Java. It discusses what applets are, how they are executed, their lifecycle methods, and how to pass parameters to applets. It also covers how to request repainting of an applet window, use the status window, and transfer control to other URLs using the AppletContext interface and showDocument method. Key aspects of the APPLET tag for embedding applets in HTML are also explained.
An applet is a Java program that runs in a web browser. Applets allow interactive components and enhancements to be added to webpages. Advantages include faster response times since applets run on the client-side, security, and platform independence. The main methods in an applet's lifecycle are init(), start(), stop(), and destroy(). Drawbacks include requiring the Java plugin to be installed in the client's browser.
An applet is a small Java program that can run in a web browser. It is embedded in an HTML page and downloaded from a server to run on a client computer. Applets have a lifecycle of initialization, startup, running, idle, and destruction. They allow for interactive graphics and animations to be added to webpages but have security restrictions around accessing files and making network connections.
This document provides an overview of Java applets and introduces some simple example applets. It discusses how applets differ from applications in that they are designed to run within a web browser or applet viewer. It then presents two simple applets - one that draws a single string and another that draws two lines of text. The document demonstrates how to create, compile, and run a basic "Hello World" style applet and provides the code and explanation for both applets. It also references chapters in the text that will provide more in-depth explanations of applet and Java concepts.
The document discusses applet programming in Java. It defines an applet as an interactive panel embedded in a web page that can be run from a browser. Applets have a life cycle of init(), start(), stop(), and destroy() methods. The paint() method is used for any drawing or painting beyond standard GUI components. Repaint() requests a repaint but does not guarantee it. Example code demonstrates basic graphics methods and includes an applet example with supporting HTML. Advantages of applets include cross-platform capability and security sandboxing, while disadvantages are needing the Java plugin and slower initial startup.
Java Applet Basics, Important points, Life cycle of an applet, AWT, AWT HIERARCHY, Creating Frame by extending Frame class, Creating Frame by creating instance of Frame class, Java Exceptions, Java try and catch, Syntax, Example for try and catch,
This document discusses the applet skeleton in Java. It explains that applets override lifecycle methods like init(), start(), stop(), and destroy() to control their execution states. These methods are defined in the Applet class. It provides a code example of an applet skeleton that implements these methods, as well as the paint() method defined in the Component class. When run, this skeleton applet generates a window to display itself.
An applet is a Java program that runs in a web browser. It extends the Applet class and does not define a main method. Applets are embedded in HTML pages and have a lifecycle of init(), start(), stop(), and destroy() methods. They can use the Graphics class to draw shapes, text, and images. Parameters can be passed to applets from the HTML code.
This document provides an introduction and overview of Java applet programming. It discusses what Java and applets are, the applet skeleton structure including common lifecycle methods like init(), start(), paint(), stop(), and destroy(). It also outlines the steps to write an applet code, compile it, and include it in an HTML file using applet tags to display the applet. An example Java applet class and HTML code is provided at the end to demonstrate a simple "Hello World" style applet.
The document discusses applet programming in Java. It defines an applet as a special type of Java program that runs in a web browser. There are two types of applets: local applets that run on the local machine, and remote applets that run on a web server. The document outlines the applet lifecycle and methods, how applets differ from other applications, the steps to develop an applet, and how to run an applet using an HTML file or the applet viewer tool.
This document provides an overview of GUI programming basics using the AWT API in Java. It discusses the key component, container and layout manager classes used to create graphical user interfaces in Java. Component classes like Button, Label and TextField are used to add interactive elements, while container classes like Frame and Panel hold other components. Layout managers help position and organize components visually. The document also provides examples of creating simple frames and applications using these AWT classes.
This document provides an overview of applet components in Java, including labels, buttons, checkboxes, choice controls, lists, scroll bars, text fields, text areas, menus, and containers. It also covers layout managers like FlowLayout, GridLayout, and BorderLayout which position components within containers. Finally, it discusses event handling using the event delegation model where sources generate events that are handled by listener interfaces like ActionListener.
Creating a frame within an applet involves:
1. Creating a subclass of Frame
2. Overriding window methods like init(), start(), stop(), and paint()
3. Implementing the windowClosing() method to call setVisible(false) when the window closes
An example program creates a SampleFrame subclass, instantiates it in the applet's init() method, and overrides start() and stop() to show/hide the frame. The frame is given a size and title and made initially invisible, later being set to visible.
This document provides an overview of the topics covered in a Core Java online training course. The course consists of 12 modules that cover Java fundamentals, OOP concepts, collections, files and I/O, threads, exceptions, JDBC and more. Each module includes topics to be covered and programming sessions to apply the concepts learned through examples and exercises.
This document discusses adopting better driving habits by using an application that identifies bad driving behaviors and translates any mishaps into donations to charitable causes, with the goal of making roads safer through self-awareness and investing in goals that motivate safer driving. The application tracks driving habits, notes any issues, and converts incidents into donations, hopefully encouraging improved behaviors and contributing to positive outcomes even if not.
This document provides an overview of basic Java programming concepts including:
- Java programs require a main method inside a class and use print statements for output.
- Java has primitive data types like int and double as well as objects. Variables are declared with a type.
- Control structures like if/else and for loops work similarly to other languages. Methods can call themselves recursively.
- Basic input is done through dialog boxes and output through print statements. Formatting is available.
- Arrays are objects that store multiple values of a single type and know their own length. Strings are immutable character arrays.
The Toolbar is a view introduced in Android Lollipop that is easier to customize and position than the ActionBar. It can be used on lower Android versions by including the AppCompat support library. To use the Toolbar as an ActionBar, disable the theme-provided ActionBar, add the Toolbar to the activity layout, and include dependencies for AppCompat and Design support libraries.
This document provides information about a Hibernate training course offered by YAAZLI INTERNATIONAL. The 16-hour course covers topics like configuring JPA/Hibernate, mapping objects and relationships, transactions, retrieving and manipulating persistent objects. It is offered in daily 2-hour crash classes, 4-hour weekend batches, or regular 3-day-a-week classes. The course is aimed at web app developers, enterprise app developers, and SQL developers who have prior Java knowledge.
This document provides information on two spring training courses offered by YAAZLI INTERNATIONAL: Spring Core and Spring Web.
The Spring Core training covers topics related to the core Spring framework including configuration, dependency injection, the bean lifecycle, data access, transactions, and Spring Boot.
The Spring Web training focuses on building web applications with Spring MVC and covers topics such as configuration, form handling, security, testing, and Spring Boot.
Both courses are 32 hours and include daily, weekend, and crash class options in Chennai, India. The target audience includes web developers and the prerequisite is Java knowledge. Contact details are provided at the end.
The document outlines a web project workshop hosted by Yaazli International that provides training on project management, full stack development, and placement assistance. The workshop covers methodologies like PMBOK and SCRUM and technologies like Java, PHP, and UI/UX design. Participants will work in minimum 2-4 member groups on a real client project using SCRUM methodology over 2-4 months of 8 hour daily sessions. The workshop aims to help participants find jobs and also provides technical and HR interview preparation assistance.
- The document discusses event handling in Java GUI programs.
- It explains the Java AWT event delegation model where event sources generate events that are passed to registered listener objects.
- An example program is shown where a button generates an ActionEvent when clicked, which is handled by a listener class that implements the ActionListener interface.
- The AWT event hierarchy and common event types like KeyEvents and MouseEvents are described. Individual events provide information about user input.
- Adapter classes are mentioned which provide default empty implementations of listener interfaces to simplify coding listeners.
This document outlines an Angular.io training course that provides 40 hours of instruction over 8 days. The course covers key Angular concepts and features through 20 sections, including components, templates, data binding, routing, and HTTP client. It is aimed at UI/UX developers and targets HTML, CSS, and JavaScript knowledge. The training has regular daily classes from 8am to 1pm and 2pm to 7pm, as well as weekend crash classes. For more information, contact Arjun Sridhar on the provided phone number or website.
Final year M.E IEEE PROJECTS TITLES 2014-2015 Final year IEEE PROJECTS TITLES 2014-2015 Final year M.TECH IEEE PROJECTS TITLES 2014-2015 Final year B.E IEEE
Exception handling in Java provides a robust way to handle errors and exceptions that occur during program execution. The try-catch block allows code to be wrapped in a try block to protect it, while catch blocks handle any exceptions. Multiple catch blocks can be used to handle different exception types. The throw keyword is used to manually throw an exception, while throws is used to indicate unhandled exceptions in a method signature. Finally, the finally block is used for cleanup and always executes regardless of exceptions.
Based on chapter 2 of the textbook "Building Java Programs", 3rd edition. Covers primitive data types, variables, operators, ASCII values for chars, operator precedence, String concatenation, casting, for loops, nested for loops, and class constants.
See a video presentation of this slideshow on my YouTube channel JavaGoddess, at https://www.youtube.com/watch?v=N7SBkMY65gc&t=4s
The singleton pattern ensures that only one instance of a class is created. It involves a class that instantiates itself and makes sure no other instances are created, providing a global point of access to the sole instance. Examples of where the singleton pattern is commonly used include logger classes, configuration classes, accessing shared resources, and singleton factories.
Esoft Metro Campus - Diploma in Web Engineering - (Module IX) Using Extensions and Image Manipulation
(Template - Virtusa Corporate)
Contents:
Image Manipulation with PHP
GD Library
ImageCreate()
ImageColorAllocate()
Drawing shapes and lines
imageellipse()
imagearc()
imagepolygon()
imagerectangle()
imageline()
Creating a new image
Using a Color Fill
imagefilledellipse()
imagefilledarc()
imagefilledpolygon()
imagefilledrectangle()
Basic Pie Chart
3D Pie Chart
Modifying Existing Images
imagecreatefrompng()
imagecolortransparent()
imagecopymerge()
Creating a new image…
Stacking images…
Imagestring()
Draw a string
This document discusses applets and basic graphics in Java. It covers applet restrictions, the applet lifecycle, loading images, and common graphics methods. Security restrictions prevent applets from accessing client files, network connections, or private user information. The document provides templates for basic applets and HTML pages to load applets. It also demonstrates how to read parameters, draw strings and shapes, and load images in applets.
This document provides an overview of Java applets including:
- Applets are programs that run in web browsers under control of the browser to provide interactive experiences on web pages.
- The lifecycle of an applet involves initialization, starting, stopping, and destruction controlled by the browser through specific methods.
- Security restrictions are placed on applets to prevent them from compromising the user's system.
This document discusses Java applets and their life cycle. It explains that applets are subclasses of Applet that run in web browsers rather than via a main method. The life cycle of an applet involves initialization, start, paint, stop, and destroy methods. It provides an example "Hello World" applet code and explains how to compile, embed in an HTML file, and run it using an applet viewer. Finally, it contrasts applets and applications, noting that applets have limited system access for security while applications are fully trusted and run via a main method.
UNIT – 4
PART I
APPLET
APPLETS - GUI COMPONENTS
APPLET PARAMETERS
LIFE CYCLE OF AN APPLET
APPLICATION CONVERSION TO APPLETS
AWT AND AWT HIERARCHY
SWING COMPONENTS
This document provides information on Java applets including:
- An applet is a Java program that runs in a web browser context
- It must extend the Applet class or JApplet class
- Includes the applet lifecycle of loading, creating, initializing, starting, stopping, and destroying
- Provides sample code for creating a basic "MyApp" applet class and embedding it in an HTML page
- Discusses restrictions on applets and demonstrates creating an applet project in NetBeans
Java programs are portable across operating systems due to three features: 1) the standardized Java language, 2) the portable class library, and 3) translating source code to portable byte code rather than platform-specific machine code. The Java language is secure through interpreter-level checks and browser-level restrictions for applets. It is also robust through features like garbage collection and bounds checking that prevent crashes. Java programs come in two flavors - standalone applications or applets for web programming. Applets have additional restrictions and predefined lifecycle methods that are automatically invoked by web browsers.
This document provides an introduction to Java applets, including how they differ from standalone applications, how they are built and used on web pages, and some key classes involved in creating applets. The key points are:
1) Applets are small Java programs that can be embedded in HTML pages and run in web browsers, allowing web pages to have interactive elements, while applications are standalone programs run with the Java interpreter.
2) Applets are built using classes like Applet and JApplet and override methods like init() instead of having a main() method. They are usually graphical and enable user interaction.
3) To create an applet, you define a public class that extends JApplet,
This document discusses Java applets. It defines an applet as a small program that performs a specific task within a larger program. The document outlines the features of applets, providing examples of how to write a basic "Hello World" applet in Java. It also describes the lifecycle of an applet, including the init, start, stop, and destroy methods. The document notes advantages of applets like platform independence, and disadvantages like requiring the Java plugin.
An applet is a small Java program that runs in a web browser. It allows for interactive graphics and animation to be embedded in HTML pages. Applets differ from standalone Java applications in that they have no main method and run within the context of a web page. The lifecycle of an applet involves initialization, starting, stopping, and destruction as the user interacts with the web page. Parameters can be passed to applets using the <param> tag in HTML. The applet code uses methods like init(), paint(), start(), and stop() to control its execution and display output.
This document provides an overview of Java basics, including:
- Java programs are portable across operating systems due to features like the Java language specification, portable class library, and use of bytecode instead of machine code.
- Java is secure due to lack of pointer arithmetic, garbage collection, bounds checking, and restrictions on applets.
- Java is robust with features that avoid crashes like bounds checking and exceptions.
- Java programs come in the form of standalone applications or applets, with differences in file I/O restrictions and need to handle browser lifecycle methods.
- The Java compiler produces bytecode files that are dynamically linked and executed by the Java runtime on any platform.
This document provides an overview of Java basics, including:
- Java programs are portable across operating systems due to features like the Java language specification, portable class library, and use of bytecode instead of machine code.
- Java is secure due to lack of pointer arithmetic, garbage collection, bounds checking, and restrictions on applets.
- Java is robust with features that avoid crashes like bounds checking and exceptions.
- Java programs come in the form of standalone applications or applets, with differences in file I/O restrictions and need to handle browser lifecycle methods.
- The Java compiler produces bytecode files that are dynamically loaded and linked at runtime.
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
- Applets are small Java applications that run within web pages. They are executed by a web browser or applet viewer once they have been compiled into class files.
- Applets have lifecycle methods like init(), start(), stop(), and destroy() that are called at different points in the applet's execution. The paint() method handles redrawing the applet's display.
- Applets can use methods like drawString() to output text and repaint() to refresh their display. Parameters can be passed to applets via the HTML <applet> tag and retrieved using getParameter().
An applet is a Java program that runs in a web browser. It can have full Java functionality. Applets have a lifecycle of init(), start(), paint(), stop(), destroy() methods. They are embedded in HTML pages and have security restrictions. The applet displays output using drawString() and requests repaints with repaint(). It can output to the browser status window.
This document discusses applet programming in Java. It covers key topics like what applets are, how they differ from applications, the applet life cycle including initialization, running, idle, and destroyed states, how to write applets including necessary tags and parameters, and graphics programming using applets. The classes inherited by applets and methods like init(), start(), stop(), destroy(), and paint() are also explained.
This document discusses Java applets, which are small Java applications that run inside web browsers. It describes how applets are embedded in webpages using the <applet> tag and can be passed parameters. The document outlines the applet architecture and lifecycle methods like init(), start(), paint(), stop(), and destroy(). It also discusses how applets can display information in the browser status window.
This document provides an overview of applet programming in Java. It discusses that applets are small Java programs that are embedded in web pages and can be transported over the Internet. The document then covers the differences between applets and standalone Java applications, the lifecycle of an applet including common methods like init(), start(), stop(), and destroy(), and provides a simple example for creating an applet program by writing the Java code, embedding it in an HTML file, and running it in a web browser or with the appletviewer tool.
Introduction to java programming. fundamentas. basic programming. java is easy to learn. following this presentation , you can get more knowledge of Java . Elementary level presentation.
This document provides an overview of Java applets and how to create a simple "Welcome" applet. It discusses how applets run inside an applet viewer or browser. The document then demonstrates how to create a simple applet class that extends Applet and overrides the paint method to draw a string. It shows the Java code for the applet class and the necessary HTML to display the applet. Finally, it discusses using additional graphics methods like drawLine to create more complex applets.
This document provides an overview of connecting to and interacting with databases using JDBC. It begins with database basics, explaining concepts like tables, records, queries, and SQL. It then covers connecting to a database with JDBC, including registering drivers and obtaining a connection. Finally, it discusses querying and manipulating databases with JDBC through executing SQL statements and processing result sets. Examples are provided to demonstrate selecting, updating, and inserting data into databases using JDBC.
This document provides an overview of networking concepts in Java including:
1) It outlines topics on networking basics like IP addresses, ports, protocols and client-server interactions.
2) It describes how to write networking clients and servers using sockets.
3) It provides an example of writing a simple ICQ client-server application to demonstrate sockets.
4) It discusses communicating with web servers by retrieving and sending information using URLs and URLConnections.
This document provides an introduction to multithreading concepts. It discusses using multiple threads to allow a bouncing ball animation program to start new balls even while others are still bouncing. It covers the basics of creating and running threads, including defining a runnable class and starting new threads. It also discusses key threading issues like thread states, scheduling, synchronization, and suspending/stopping threads.
This document provides an overview of Swing components for creating graphical user interfaces in Java. It discusses top-level containers like JFrame and JDialog, general purpose containers like JPanel and JScrollPane, basic controls for user input like JTextField and JButton, components for displaying information like JLabel and JTable, and various layout managers including FlowLayout, BorderLayout, GridLayout, BoxLayout, and GridBagLayout. It also covers using borders with components and implementing listeners for text fields. The document is intended to teach what is needed to create full-featured GUIs with Swing.
1) The document discusses the basics of GUI programming using Swing in Java, including creating frames, panels, and displaying text, shapes, colors, fonts, and images.
2) It explains how to create a JFrame window, add JPanels, and override the paintComponent method in custom JPanel classes to draw desired graphics.
3) Specific examples are provided for displaying text by drawing strings, using different fonts, colors, and measuring text widths using FontMetrics.
This document discusses exceptions in Java. It covers Java exception classes like Error, RuntimeException, IOException which are unchecked and checked exceptions. It explains how to deal with exceptions by throwing exceptions from methods using throws and catching exceptions using try-catch blocks. Finally, it discusses concepts like multiple catch blocks, finally clause, and exception handling mechanism in Java.
This document provides an overview of input and output (I/O) in Java, including reading and writing local files. It discusses Java streams for reading input and writing output, and the classes for character-based and byte-based streams. The document outlines connecting to files, reading and writing characters and objects to files, and file management tasks like creating directories and deleting files.
This document provides an overview of inheritance in Java. It begins with an introduction to inheritance concepts like superclass, subclass, overriding methods, and polymorphism. It then covers deriving a subclass, including subclass fields, constructors, and methods. It discusses using subclasses and notes on this, super, and protected access. It concludes with special class types like abstract classes, which can contain abstract methods, and final classes/methods, which cannot be overridden.
Classes and objects are the main building blocks in object-oriented programming. A class acts as a blueprint that defines the attributes and behaviors of objects. It contains fields to represent an object's state, methods to represent its behaviors, and constructors to initialize new objects. Methods can be used to encapsulate an object's state through getter and setter accessors. Classes allow for code reuse through inheritance and polymorphism. Packages are used to organize related classes and avoid naming collisions.
This document provides an overview of advanced programming techniques in Java. It begins by comparing Java to C and C++, noting how Java simplified aspects of these languages while adding object-oriented features. It then outlines several advantages of Java, such as its simplicity, object-oriented design, platform independence, and robustness. The document also discusses Java's extensive standard libraries, known as packages, and how they provide powerful functionality and handle platform-specific details. It notes that Java is well-suited for networked and distributed applications, especially on the internet, due to its portability, multithreading, and networking capabilities. The course will cover fundamental Java concepts like classes, objects, inheritance and exceptions, as well as components, mult
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
2. Introduction
• Applets are java programs that run within browsers
• Example:
– Jmol applet
• http://jmol.sourceforge.net/applet/
– NASA 3D real-time satellite tracker
• http://liftoff.msfc.nasa.gov/realtime/jtrack/3d/JTrack3d.html
Applet
Client Browser ServerApplet
User
3. Outline
• An example
• Creation
– Converting applications to applets
• Transportation
– Jar files: Move applets from servers to browsers quickly
• Operation
– Applet life cycle
– Security restrictions
– Getting resources from home
– Communicating with browser
Applet
Client Browser ServerApplet
User
4. An Example
An applet is a Java class which extends java.applet.Applet
If Swing components are used, the applet must extend from
javax.swing.JApplet
public class NotHelloWorldApplet extends JApplet
{ public void init()
{
Container contentPane = getContentPane();
JLabel label = new JLabel("Not a Hello,
World applet", SwingConstants.CENTER);
contentPane.add(label);
}
} //NotHelloWorldApplet.java
5. • Compile and run
– Compile: javac NotHelloWorldApplet.java
– Run:
• Create a HTML file that tells the browser which file to load and how to size the applet
<html><body> This is an example.
<applet code=“NotHelloWorldApplet.class” width=300
height=300>
This text shown if browser doesn’t do Java.</applet>
</body></html>
• View the HTML file with a browser or the command appletviewer
– Note:
• Textpad: Cntrl+3 – creates a simple html file and show it with appletviewer
An Example
6. An Example
• More notes
– To view applet, one needs Java 2 enabled browser (recent version of IE
and Netscape, e.g. IE 6, Netscape 6, Netscape 7. Netscape 4 is not Java
2 enabled)
– Class files are cached by browser.
• Restart browser after each modification
• Alternatively, one can clear the cache from Java console, which can be
accessed from Netscape or control panel on Windows
8. • Compare with application: NotHelloWorld.java
class NotHelloWorldFrame extends JFrame
{
public NotHelloWorldFrame()
{
setTitle("NotHelloWorld");
setSize(300, 200);
Container contentPane = getContentPane();
JLabel label = new JLabel("Not a Hello,
World application", SwingConstants.CENTER);
contentPane.add(label);
}
}
public class NotHelloWorldApplication
{ public static void main(String[] args)
{ NotHelloWorldFrame frame =
new NotHelloWorldFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}}
An Example
9. • Applets are created, run, and destroyed by web browser
– Don’t set size for an applet: determined by HTML file.
– Don’t set title for an applet: applets cannot have title bars.
• Can have menus.
– No need to explicitly construct an applet. Construction code placed inside the
init method.
– There is no main method.
– An applet cannot be closed. It terminates automatically when the browser exit.
– No need to call method show. An applet is displayed automatically.
An Example
10. Outline
• An example
• Creation
– Converting applications to applets
• Transportation
– Jar files: Move applets from servers to browsers quickly
• Operation
– Applet life cycle
– Security restrictions
– Getting resources from home
– Communicating with browser
11. Creating Applets from Applications
• Non-IO applications for now
– Pop up window for application
– Embed top-level frame of application inside
browser
12. Creating Applets from Applications
• Popping up a window for application.
– Assume: Separate class for creating and showing a top-level frame. (If this
class also does some other things, move the other things to other classes.)
class NotHelloWorldFrame extends JFrame {…}
public class NotHelloWorldApplication
{ public static void main(String[] args)
{ JFrame frame = new NotHelloWorldFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
13. Creating Applets from Applications
• Steps of conversion:
– Delete the class for creating and showing the top-level frame
– Add an applet class whose init method contains the same instructions as
main method of deleted class.
– Remove code for closing window
public class NHWApplet extends JApplet
{ public void init()
{ JFrame frame = new NotHelloWorldFrame();
frame.show();
}
} //NHWApplet.java
– The popup window coming with a warning message for security reasons,
(which can be avoided for signed applets).
14. Creating Applets from Applications
• Placing top-level frame of application inside browser.
– Separate class for creating and showing a top-level frame. (If this class also
does some other things, move the other things to other classes.)
class NotHelloWorldFrame extends JFrame
{
public NotHelloWorldFrame()
{
setTitle("NotHelloWorld");
setSize(300, 200);
Container contentPane = getContentPane();
JLabel label = new JLabel("Not a Hello, World applet", SwingConstants.CENTER);
contentPane.add(label);
}}
public class NotHelloWorld
{ public static void main(String[ ] args)
{ NotHelloWorldFrame frame = new NotHelloWorldFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}}
15. Creating Applets from Applications
• Steps of conversion
– Delete the class for creating and showing the top-level frame
– Convert the top-level frame class into an applet
• JFrame class => JApplet class; must be public
• Remove setSize: set in HTML file
• Remove setTitle: Applet cannot have title bar
• Replace constructor with init.
16. Creating Applets from Applications
• Let’s do it now
class NotHelloWorldFrame extends JFrame
{
public NotHelloWorldFrame()
{
setTitle("NotHelloWorld");
setSize(300, 200);
Container contentPane = getContentPane();
JLabel label = new JLabel("Not a Hello, World applet", SwingConstants.CENTER);
contentPane.add(label);
}}
public class NotHelloWorld
{ public static void main(String[ ] args)
{ NotHelloWorldFrame frame = new NotHelloWorldFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}}
17. Outline
• An example
• Creation
– Converting applications to applets
• Transportation
– Jar files: Move applets from servers to browsers quickly
• Operation
– Applet life cycle
– Security restrictions
– Getting resources from home
– Communicating with browser
18. Transportation of Applets via Jar Files
• PopupCalculatorApplet involve three classes
– CalculatorFrame.class, CalculatorPanel.class
PopupCalculatorApplet.class
• HTML file contains name of the applet class
– <APPLET CODE=" PopupCalculatorApplet.class " WIDTH = 60
HEIGHT = 20 > </APPLET>
• Class loader
– First fetches PopupCalculatorApplet.class
– In the process, it notices that some other classes are also needed. It then makes net
connections to get them.
– Many connections might be needed in general, especially when there are associated
resources such as images and sounds.
19. Jar Files
• Jar files
– A jar file is simply a zip file that contains a manifest file, which
describes features of the archive
– Java Archive (JAR) files allow one to bundle a set of classes and resources into
one file that can be downloaded via one net connection.
20. Jar Files
• Creating jar files
– jar cf PopupCalculatorAppletClasses.jar *class
• In general:
jar cf myJarFile.jar *.class *.gif
pack all files ending with .class or .gif
21. Jar Files
Refer to JAR files in the APPLET tag
<APPLET CODE="PopupCalculatorApplet.class"
ARCHIVE="PopupCalculatorAppletClasses.jar,swing.jar"
WIDTH = 65 HEIGHT = 20 > </APPLET>
JAR file is downloaded via one net connection.
Class loader tries to find necessary files in JAR file before attempting
to get them from the net.
22. Diversion/Self-Running Jar File
• “To make an executable jar file, we need to indicate the main class in the
manifest file.
– Create “mainclass.mf” with one line (no “class” and ended by “return”)
Main-Class: MyApplet
– Create jar file with the manifest file
jar cvfm MyJarFile.jar mainclass.mf *class
– Also, one can update the manifest files of an existing jar file
jar umf mainclass.mf MyJarFile.jar
• Run:
– java -jar MyJarFile.jar
– Or click on file icon
Self-Running Calculator
23. Outline
• An example
• Creation
– Converting applications to applets
• Transportation
– Jar files: Move applets from servers to browsers quickly
• Operation
– Applet life cycle
– Security restrictions
– Getting resources from home
– Communicating with browser
24. Applet Life Cycle
• An application starts from main and runs
until exit
• Applets are controlled by browser through
4 methods
– init()
• Called when loaded by browser
– start()
• Called right after init and when user return
to page
– stop()
• Called when user moves off page
– destroy()
• Called when browser shuts down.
• Overwrite the methods to control applet
behavior
non-existent on page
off page
init( )
destroy( )
stop( )destroy( ) start( )
25. Applet Life Cycle
• public void init()
– One-time initialization when first loaded
– Good place to process parameters and add interface components.
• public void start()
– Called whenever user returns to the page containing the applet after
having gone off to other pages.
– Can be called multiple times.
– Good place to resume animation or game
26. Applet Life Cycle
• public void stop()
– Called when user moves off page (to other pages)
– Good place to stop time-consuming activities such as animation and audio
playing.
• public void destroy()
– Called when browser shuts down.
– Good place to reclaim non-memory-dependent resources such as graphics
contexts.
– Normally, no need to worry.
• Example: sound (Stop Playing when going out of page)
Compare with the one of the two other versions.
27. Outline
An example
Creation
Converting applications to applets
Transportation
Jar files: Move applets from servers to browsers quickly
Operation
Applet life cycle
Security restrictions
Getting resources from home
Communicating with browser
28. Security Restrictions
Applets are downloaded from the net and executed by a
browser’s JVM immediately.
User never gets a chance to confirm or to stop an applet from
running.
Consequently, applets are restricted in what they can do.
The applet security manager is responsible for enforcing access
rules and throws an SecurityException when an access
rule is violated.
29. Security Restriction
By default, an applet is restricted to run “inside the
sandbox”. Strictest security restrictions.
Signed applets can have more access privileges.
For now, we consider only applets playing in the
sandbox.
30. Access rights for Applets and Java Applications (JA)
BR: applets running inside a browser with default applet
security model
AV: applets running insider Applet viewer
BR
Read local file N
Write local file N
Get file info. N
Delete file N
Run another program N
Read the user.name property N
Connect to network port on home server Y
Connect to network port on other server N
Load Java library N
Call exit N
Create a pop-up window warning
AV JA
Y Y
Y Y
Y Y
N Y
Y Y
Y Y
Y Y
Y Y
Y Y
Y Y
Y Y
31. Outline
An example
Creation
Converting applications to applets
Transportation
Jar files: Move applets from servers to browsers quickly
Operation
Applet life cycle
Security restrictions
Getting resources from home
Communicating with browser
Applet
Client Browser ServerApplet
User
32. Resources for Applets
One can provide information to applets in HTML file
Applets can access resources at home server:
Text
Multimedia
33. Passing Info to Applets via HTML File
In HTML file, use PARAM, NAME, VALUE tags
<APPLET CODE="Chart.class" WIDTH=400 HEIGHT=300>
<PARAM NAME="title" VALUE="Diameters of the Planets">
<PARAM NAME="values" VALUE="9">
…. </Applet>
In applet, use the getParameter method of the Applet class
getParameter("title"); // returns "Diameters of the Planets“
String vString = getParameter(“values”); // returns “9”
if (vString == null )
{do something} // precaution
else
int v=Integer.parseInt(vString);//must parse to get numbers
Chart.java, Chart.html
34. Accessing Resources at Home Server
Where is home?
Inside a subclass of Applet
getDocumentBase returns URL of the html file that calls the
applet
getCodeBase returns URL of the applet itself
Inside any other class x
x.class gives one an object of the Class class that contain
information of x.
(Class is a special class and has method getResource.
C.f. Object class)
x.class.getResource( resourceName ) returns URL
of resource
Need the URL class in java.net package
import java.net.*
35. Accessing Text Files at Home Server
Find the URL of text file and the create an InputStream using
the openStream method of URL class
InputStream in = url.openStream();
Or create an InputStream directly using the
getResourceAsStream method of the Class class.
InputStream in = x.class.getResoruceAsStream(
fileName);
The InputStream can be nested with other streams in the
normal way (see Topic 4)
ResourceTest.java, ResourceTest.html
36. Applets can handle images in GIF or JPEG format
Load images
Inside an subclass Applet, use
getImage(url), getImage(url, name)
Inside other classes java.awt.Toolkit
Toolkit.getDefaultToolkit().getImage( url );
How to show an image?
ImageLoadApplet.java
Accessing Images at Home Server
Exercise: Load the images in applet class
37. Applets can handle audio files in AU, AIFF, WAV, or
MIDI format.
Audio Clips (java.applet.Applet)
Load:
AudioClip getAudioClip(url),
AudioClip getAudioClip(url, name)
Then use play method of AudioClip to play
and the stop method to stop
Play without first loading:
void play(url),
void play(url, name)
//SoundApplet.java
Accessing Audio Files at Home Server
38. Outline
An example
Creation
Converting applications to applets
Transportation
Jar files: Move applets from servers to browsers quickly
Operation
Applet life cycle
Security restrictions
Getting resources from home
Communicating with browser
Applet
Client Browser ServerApplet
User
39. Communication with Browser
To establish a communication channel between an applet and
browser, use the getAppletContext method of the Applet
class
The method returns an object of the AppletContext, which is
an interface.
Two useful methods of interface AppletContext
showDocument( URL url )
showDocument(URL url, String target )
ShowPageApplet.java
40. Java Web Start
• A technology for simplifying deployment of Java applications
– Gives you the power to launch full-featured applications with a single
click from your Web browser.
– The Java Web Start software is the reference implementation for the
Java Network Launching Protocol (JNLP)
– http://java.sun.com/products/javawebstart/docs/developersguide.html
41. Java Web Start
• What do you need?
– Jar files that contain class files & resources.
– A jnlp file for the application
– A link from the Web page to the JNLP file
– Configure the Web server so that the .jnlp file extension invokes Web Start
.(http://java.sun.com/products/javawebstart/docs/developersguide.html#web
site)
• Client side:
– Install Java Web Start, included in Download J2SE 5.0 JRE/SDK (jdk1.5.1)
42. Java Web Start
• Example 1 (javaWebStartExamples.zip):
– NotHelloWorld.jar generated from
NotHelloWorld.java
– NotHelloWorld.jnlp
See next page
– index.html
<a href="http://www.cs.ust.hk/~lzhang/teach/java03/webStart/NotHelloWorld.jnlp">
NotHelloWorld Application</a>
44. Java Web Start
• Unlike applets, web-start applications have a main() like normal Java
applications. There are a few special requirements:
• The application must be contained in a jar file
• By default restricted to Sandbox as Applets (cannot call standard IO libaries to
access the disk, you can only connect back the source host etc).
• Resources (files, images) must also be in a jar file and must be accessed using the
getResource() method.
• Like applets users can grant more access if they trust your code
• A JNLP API is required for some applications.
45. Java Web Start
• Web-start applications differ from applets in several ways:
– They are stored in the local disk so do not need to be downloaded each time.
– They can call System.exit().
– They do not have the same lifecycle.
– A web-start application can use a special class library which allows the
application to prompt users to approve reading and writing to/from the local
disk.
– Rather than HMTL tags in a web-page, XML (JNLP) is used to describe web-
start applications.
46. Java Web Start
• Example 2: ImageTest
– ImageTest.java
• Loading image using the getResource method
– ImageTest.jar
• Includes class files & image files
– ImageTest.jnlp
– Index.html
<a href="http://www.cs.ust.hk/~lzhang/teach/java03/webStart/ImageTest.jnlp">
ImageTest Application</a>