Java Applets / Flash

Similar documents
Java. GUI building with the AWT

CHAPTER 2. Java Overview

GUI in Java TalentHome Solutions

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

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Java - Applets. public class Buttons extends Applet implements ActionListener

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

SNS COLLEGE OF ENGINEERING, Coimbatore

Introduction. Introduction

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

Sri Vidya College of Engineering & Technology

Overloading Example. Overloading. When to Overload. Overloading Example (cont'd) (class Point continued.)

The Java Programming Language Basics. Identifiers, Keywords, and Types. Expressions and Flow Control. Object-Oriented Programming. Objects and Classes

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

Programming Mobile Devices J2SE GUI

Applet. 1. init (): called once by the applet containers when an applet is loaded for execution.

(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

Java - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything.

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

1 GUI GUI GUI GUI GUI. GUI(Graphical User Interface) JDK java.awt. ? Component

Java Applet & its life Cycle. By Iqtidar Ali

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

G51PRG: Introduction to Programming Second semester Applets and graphics

Graphical User Interface (GUI)

Chapter 12 Advanced GUIs and Graphics

Graphical User Interface (GUI)

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

Programming graphics

2110: GUIS: Graphical User Interfaces

SD Module-1 Advanced JAVA

Graphic User Interfaces. - GUI concepts - Swing - AWT

SD Module-1 Advanced JAVA. Assignment No. 4

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

Packages: Putting Classes Together

OBJECT ORIENTED PROGRAMMING. Course 8 Loredana STANCIU Room B613

Graphical User Interfaces. Comp 152

The AWT Package, An Overview

An Introduction To Graphical User Interfaces

Window Interfaces Using Swing Objects

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

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Component Based Software Engineering

CSC207H: Software Design Lecture 11

Systems Programming Graphical User Interfaces

Java Event Handling -- 1

Agenda. Container and Component

Window Interfaces Using Swing Objects

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

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

Dr. Hikmat A. M. AbdelJaber

Computer Programming Java AWT Lab 18

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

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!

User interfaces and Swing

Advanced Java Programming

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

Java Applet Basics. Life cycle of an applet:

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions.

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

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

CS 251 Intermediate Programming GUIs: Components and Layout

SIMPLE APPLET PROGRAM

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { }

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Chapter 7: A First Look at GUI Applications

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

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

Introduction... xv SECTION 1: DEVELOPING DESKTOP APPLICATIONS USING JAVA Chapter 1: Getting Started with Java... 1

Introduction to the JAVA UI classes Advanced HCI IAT351

Part 3: Graphical User Interface (GUI) & Java Applets

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

CS 3331 Advanced Object-Oriented Programming Final Exam

GUI Event Handlers (Part I)

Swing UI. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

7. Program Frameworks

MODULE 8p - Applets - Trials B

Arrays of Buttons. Inside Android

Applets as front-ends to server-side programming

Object Oriented Design & Patterns. Part 1

10/11/18. Introduction Panel Class Window Class Dialog class FileDialog class Menu, MenuItem class

Graphical User Interfaces in Java - SWING

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Introduction to Java Programming

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

JAVA PROGRAMMING COURSE NO. IT-705(A) SECTION - A

CSC 551: Web Programming. Fall 2001

Top-Level Containers

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

The AWT Component Library 10

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

Introduction to Java Programming

CS 170 Java Programming 1. Week 9: Learning about Loops

Transcription:

Java Applets / Flash

Java Applet vs. Flash political problems with Microsoft highly portable more difficult development not a problem less so excellent visual development tool

Applet / Flash good for: situations involving complex user input where XHTML input elements are not adequate animated output

Applet / Flash Pitfalls some users disable plug-ins/applets not available on all platforms input/output can not be handled in a standard way (assistive technology for people with disabilities)

Applet Security applets cannot: read/write files on the client file system open network connections (other than to the machine that the applet was loaded from) launch applications on the client system read certain properties of the VM

Embedding an Applet in a Page <object classid="java:path to class file" width="width in pixels" height="height in pixels"> <param name="name1" value="value1" /> <param name="name2" value="value2" />... Your browser doesn't support the object tag. </object>

<object classid="java:applet1.class" width="200" height="100"> <param name="message" value="hello!" /> Your browser doesn't support the object tag. </object>

import java.applet.applet; import java.awt.*; import java.awt.event.*; public class applet1 extends Applet { public void paint(graphics g) { g.drawstring( System.getProperty( "java.version" ), 20, 20 ); g.drawstring( System.getProperty( "java.vendor" ), 20, 40 ); } } g.drawstring( getparameter( "message" ), 20, 60 );

Applet Control Methods invoked by the containing browser init() - called once after the applet object is constructed start() - called each time applet is activated (becomes visible, etc.) stop() - called each time applet is deactivated (becomes invisible, etc.) destroy() - called once before applet is garbage collected

Controlling the Browser the Applet class has a getappletcontext method which returns an object allowing the applet to control its environment the AppletContext class has three methods for controlling the browser: showdocument( URL url ) showdocument( URL url, String target ) showstatus( String status )

import java.applet.applet; import java.awt.*; import java.awt.event.*; public class applet1 extends Applet {... URL newurl( http://www.abc.com ); AppletContext ac = getappletcontext(); } ac.showstatus( Clever message ); ac.showdocument( newurl, _blank ); ac.showdocument( newurl );...

AWT Abstract Window Toolkit platform independent GUI toolkit written in Java event driven

Component class base class for all visible elements paint() method overridden by child classes to give component specific rendering repaint() method used to trigger the painting of the component add***listner() method to control the distribution of events

Listeners low level addkeylistener addmouselistener addmousemostionlistener high level addactionlistener

JavaBeans: Indexed Properties for properties that can have multiple values, use the following pattern: public String[] getfoo(); public void setfoo( String[] value ); public String getfoo( int index ); public void setfoo( int index, String value );

JavaBeans: Indexed Properties there are no JSP tags for accessing individual elements of an indexed property use JSP expressions instead: <jsp:usebean id= somebean class= FooBean scope= page />... <%= somebean.getfoo( 7 ) %>

AWT: Simple Components Component Button Label TextComponent Checkbox Canvas TextField TextArea

Buttons simple push button Button b = new Button( Push Me! ); b.addactionlistener( myapplet ); b.setactioncommand( push );

public class applet1 extends Applet implements ActionListener {... void actionperformed( ActionEvent e ) { switch ( e.getactioncommand() ) { case push :... case pull :... }... }

Checkbox Checkbox cb = new Checkbox( Fries with that? ); cb.additemlistener( myapplet );

public class applet1 extends Applet implements ItemListener {... void itemstatechanged( ItemEvent e ) { switch ( e.getstatechange() ) { case SELECTED:... case DESELECTED:... }... }

AWT: Containers Component Container Panel Window Applet Frame

AWT: Containers Panel subwindow Window top level window; free to be moved, resized, etc adding compenents to a container: myapplet.add( b ); myapplet.add( cb );...

AWT: Containers: Layouts used to control how childen are laid out inside a container choices: FlowLayout (default), BorderLayout, GridLayout, GridBagLayout setting the layout: myapplet.setlayout( new BorderLayout() ); myapplet.setlayout( new GridLayout( rows, cols ) );

BorderLayout only one component per position when adding components, must also specify position: BorderLayout.NORTH BorderLayout.SOUTH BorderLayout.EAST BorderLayout.WEST BorderLayout.CENTER myapplet.add( b, BorderLayout.EAST );

AWT: Menus MenuComponent MenuItem MenuBar Menu

Menus: Example Menu m = new Menu( File ); MenuItem i1 = new MenuItem( New ); i1.addactionlistener( myapplet ); i1.setactioncommand( new ); MenuItem i2 = new MenuItem( Open ); MenuItem i3 = new MenuItem( Save ); MenuItem i1 = new MenuItem( Save As... ); m.add( i1 ); m.add( i2 ); m.add( i3 ); m.add( i4 );

Cascading menus Menu m2 = new Menu( foo ); MenuItem i10 = new MenuItem( xyz ); MenuItem i11 = new MenuItem( abc ); m2.add( i10 ); m2.add( i11 ); m2.add( m ); // menu from previous slide