Framework. Set of cooperating classes/interfaces. Example: Swing package is framework for problem domain of GUI programming

Similar documents
Framework. Set of cooperating classes/interfaces. Example: Swing package is framework for problem domain of GUI programming

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Contents 8-1. Copyright (c) N. Afshartous

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

Unit 1- Java Applets. Applet Programming. Local Applet and Remote Applet ** Applet and Application

Chapter 7 Applets. Answers

Road Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 9: Writing Java Applets. Introduction

Module 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet

SIMPLE APPLET PROGRAM

UNIT-2: CLASSES, INHERITANCE, EXCEPTIONS, APPLETS. To define a class, use the class keyword and the name of the class:

CS2 Advanced Programming in Java note 8

Java Applets / Flash

Outline. Announcements. Feedback. CS1007: Object Oriented Design and Programming in Java. Java beans Applets

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

PROGRAMMING LANGUAGE 2

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1

Overview. Applets. A Java GUI inside your browser! Important methods Drawing images Playing audio Getting input parameters Double buffering

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet

SELF-STUDY. Glossary

Java Application Development

Introduction to Java Applets 12

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

SNS COLLEGE OF ENGINEERING, Coimbatore

9. APPLETS AND APPLICATIONS

UNIT -1 JAVA APPLETS

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B

PART1: Choose the correct answer and write it on the answer sheet:

5. In JAVA, is exception handling implicit or explicit or both. Explain with the help of example java programs. [16]

MULTIMEDIA PROGRAMMING IN JAVA. Prof.Asoc. Alda Kika Department of Informatics Faculty of Natural Sciences University of Tirana

(Refer Slide Time: 02:01)

Summary. 962 Chapter 23 Applets and Java Web Start

Java Applet & its life Cycle. By Iqtidar Ali

G51PRG: Introduction to Programming Second semester Applets and graphics

Applets as front-ends to server-side programming

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

The init() Method. Browser Calling Applet Methods

Lecture Static Methods and Variables. Static Methods

SCHEME OF COURSE WORK

CSC System Development with Java Introduction to Java Applets Budditha Hettige

PESIT Bangalore South Campus

Chapter 13. Applets and HTML. HTML Applets. Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

OBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613

Chapter 3 - Introduction to Java Applets

GUI, Events and Applets from Applications, Part III

Programming graphics

CSCE3193: Programming Paradigms

GUI Components: Part 1

This page intentionally left blank

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

Java Programming Lecture 6

Java Programming Unit 6. Inner Classes. Intro to Apples. Installing Apache Tomcat Server.

Big Java Late Objects

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Lecture Static Methods and Variables. Static Methods

Introduction to Java.net Package. CGS 3416 Java for Non Majors

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Core JAVA Training Syllabus FEE: RS. 8000/-

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Today. cisc3120-fall2012-parsons-lectiv.2 2

No. of Printed Pages : 5. MCA (Revised) / BCA (Revised) Term-End Examination December, :360. Student (name, age, programme)

CS 3331 Advanced Object-Oriented Programming Final Exam

Basic Java Network Programming. CS211 July 30 th, 2001

Chapter 14: Applets and More

8/23/2014. Chapter Topics. Introduction to Applets. Introduction to Applets. Introduction to Applets. Applet Limitations. Chapter 14: Applets and More

CSC 551: Web Programming. Fall 2001

JAVA BASICS II. Example: FIFO

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

2. (True/False) All methods in an interface must be declared public.

JAVA MOCK TEST JAVA MOCK TEST III

Chapter 14: Applets and More

Building custom components IAT351

15CS45 : OBJECT ORIENTED CONCEPTS

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

Object Oriented Programming Concepts-15CS45

Introduction to the JAVA UI classes Advanced HCI IAT351

1 OBJECT-ORIENTED PROGRAMMING 1

Rich Client Viewer (applet)

CS335 Graphics and Multimedia

Chapter 1 Introduction to Dreamweaver CS3 1. About Dreamweaver CS3 Interface...4. Creating New Webpages...10

A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p.

C ONTENTS PART I FUNDAMENTALS OF PROGRAMMING 1. and Java 3. Chapter 1 Introduction to Computers, Programs,

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.

User interfaces and Swing

Object-Oriented Programming EE219 Repeat 2004/2005 Page 1 of 8

Lecture 19 GUI Events

Java 1.8 Programming

Merge Sort Quicksort 9 Abstract Windowing Toolkit & Swing Abstract Windowing Toolkit (AWT) vs. Swing AWT GUI Components Layout Managers Swing GUI

The Servlet Life Cycle

ASSIGNMENT NO 14. Objectives: To learn and demonstrated use of applet and swing components

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

CSE 331 Software Design & Implementation

Chapter 6 Introduction to Defining Classes

Transcription:

Frameworks 1

Framework Set of cooperating classes/interfaces Structure essential mechanisms of a problem domain Programmer can extend framework classes, creating new functionality Example: Swing package is framework for problem domain of GUI programming 2

Frameworks Vs. Patterns Pattern: general design rule for solving a problem Framework: set of classes providing functionality in a particular domain; often uses multiple patterns 3

Application Frameworks Implement services common to any type of application Supply sets of classes for programmer to augment to build applications (often by subclassing framework classes) 4

Inversion of Control Framework classes, not application-specific classes, control flow of execution Framework determines which methods to call and when 5

Framework example: Applets Applet: Java program that can be included in a web document to add interactions and dynamism Java source is referenced by an HTML document Package java.applet is a simple application framework consists of superclasses to make applets programmer adds classes, overrides methods to create actual applets 6

Applet characteristics No main() method Programmer overrides some or all of the following methods: init() start() stop() destroy() paint() 7

How applets work Since an applet has no main() method, initialization of object takes place in method init(), which takes the place of both main() and the constructor Method init() is typically used to perform initializations of short duration; longer running initializations, e.g. loading a file across a network, should be done in separate threads 8

Methods of Applet class Method init() is empty, and must be overridden by the child class Method start() is called to set up the applet to run may create several threads called when applet is loaded & initialized the first time, resized, or when user returns to page from elsewhere paint() automatically called after start() 9

Methods of Applet class Method stop() is called to stop the applet - usually means halting threads started by start() when, for example, the user leaves the page Method destroy() performs final cleanup before the applet is unloaded 10

Methods of Applet class Control sequence is: init() start() paint() then stop() or destroy(), as appropriate Applet can transition many times between start() and stop() states May define all, some, or none of these methods when extending an Applet; should only define those necessary for specific applet 11

HTML for applet inclusion <APPLET codebase = URL for code location code = class name width = # height = #> <param name = somename value = value> Alternate text to display in lieu of applet </APPLET> 12

Applet HTML dissected Codebase: URL web address where code can be found (can be just a file name) code: name of class (name of file in an application) height and width tell browser how much space to allocate for applet param tags: provide parameters, analogous to command-line parameters - values can be accessed within applet via call to getparameter() 13

More fun facts about applets Applet class is actually subclass of Panel - so inherits graphical component attributes Events, in particular, are handled same way as other graphical components, and window repainting same as application Default layout for applet is flow layout, not border layout 14

Other methods provided by Applet class getimage(url): takes URL and retrieves image from that location (must be gif or jpg) getaudioclip(url): returns audio object from given location; can subsequently be asked to play - shorthand version play(url) combines get and play methods 15

Other methods provided by Applet class getcodebase() returns URL for codebase specified for applet getparameter() takes String argument and returns associated String value if <param> tag was provided - returns null if none was provided 16

Java class URL URL class is provided by java.net.* URL object supplies methods to parse URL, open network connections, and retrieve information Example: URL newurl = new URL(String s); creates URL object newurl with specification s 17

Java class URL Can create URLs using Java s URL class - address is formed from a String, or previous URL plus a String - latter from could be used, for example, to retrieve several files from the same directory URL class provides method openstream, which returns an InputStream value - once an URL object is created, can use this method to read from the URL using normal InputStream methods 18

Using applet to open a new page Can use showdocument() method of class appletcontext to instruct browser to load a new web page: appletcontext.showdocument(url) URL refers to a Java URL object (not a string) browser will display the page corresponding to the URL 19

Applets vs. Applications An applet has no main method, as it is structured to run inside another application The Java Virtual Machine runs applications, but not applets Can use appletviewer program to test and debug applet code Most applets are event-driven (but don t have to be) 20

Applets vs. Applications Applets do I/O through the browser GUI, and displays error messages (only) to stdout An applet is a subclass of Applet from java.applet Applets have security restrictions: can t read or write files, run local executable programs, communicate with hosts other than the server, or learn many facts about the client computer 21

Creating Applet/Application Hybrids Applet class pays no attention to static methods contained in class definition Key idea is that Applet is a Panel can nest inner class within Applet to create Frame necessary for application only component created for this Frame will be Panel constructed by Applet Method main(), which is ignored when executing as applet, creates instance of applet when run as an application Applet then creates instance of Frame, placing itself in center Constructor for Frame executes requisite init() and start() 22

Applets as Framework Programmer for individual applet uses inheritance to extend the applet framework class to specific program Applet class deals with behavior common to all applets; programmer only fills in custom behavior for specific application 23

Applets as Framework Inversion of control means applet programmer not concerned with overall control flow - fills in handlers for initialization, starting, stopping and painting, but has no control over when these methods are called 24