Java Applets This is not a Java course! (You re supposed to know about Java.)

Similar documents
Comparison with MySQL

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

Graphic User Interfaces. - GUI concepts - Swing - AWT

Java Programming Lecture 6

Graphical User Interface (GUI)

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

Programming graphics

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Introduction. Introduction

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

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

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

Graphical User Interfaces. Comp 152

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!

SIMPLE APPLET PROGRAM

Chapter 7 Applets. Answers

Graphical User Interface (GUI)

G51PRG: Introduction to Programming Second semester Applets and graphics

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

User interfaces and Swing

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

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

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

Introduction to the JAVA UI classes Advanced HCI IAT351

The init() Method. Browser Calling Applet Methods

H212 Introduction to Software Systems Honors

EVENTS, EVENT SOURCES AND LISTENERS

SELF-STUDY. Glossary

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

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

PROGRAMMING LANGUAGE 2

CSC 1214: Object-Oriented Programming

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

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

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

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

Chapter 12 Advanced GUIs and Graphics

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

CS 251 Intermediate Programming GUIs: Components and Layout

CSCI 053. Week 5 Java is like Alice not based on Joel Adams you may want to take notes. Rhys Price Jones. Introduction to Software Development

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

JAVA Swings Sample Codes CODE NO: EduLanka Sample Java Codes - ONLINE JAVA

Graphical User Interface (GUI) and Object- Oriented Design (OOD)

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

CS Exam 1 Review Suggestions

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

We are on the GUI fast track path

Programming Languages and Techniques (CIS120)

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

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet

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

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

COSC 123 Computer Creativity. Graphics and Events. Dr. Ramon Lawrence University of British Columbia Okanagan

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Today. cisc3120-fall2012-parsons-lectiii.3 2

Recitation 02/02/07 Defining Classes and Methods. Chapter 4

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

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

Unit 6: Graphical User Interface

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Class 16: The Swing Event Model

1.00/ Introduction to Computers and Engineering Problem Solving. Quiz 2 / November 5, 2004

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords


Chapter 12 GUI Basics

Contents Introduction 1

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

Swing Programming Example Number 2

DEMYSTIFYING PROGRAMMING: CHAPTER FOUR

Human-Computer Interaction IS4300

Introduction to concurrency and GUIs

CSC System Development with Java Introduction to Java Applets Budditha Hettige

DM503 Programming B. Peter Schneider-Kamp.

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

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

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Java Applet & its life Cycle. By Iqtidar Ali

Widgets. Widgets Widget Toolkits. User Interface Widget

Chapter 3 - Introduction to Java Applets

Chapter 4. Swing 18 marks

Java: Graphical User Interfaces (GUI)

Java Applet Basics. Life cycle of an applet:

Object-Oriented Programming: Revision. Revision / Graphics / Subversion. Ewan Klein. Inf1 :: 2008/09

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

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Java - Applets. public class Buttons extends Applet implements ActionListener

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

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

Here is a list of a few of the components located in the AWT and Swing packages:

To gain experience using GUI components and listeners.

(Incomplete) History of GUIs

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

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

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

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2012

Transcription:

IT 3203 Introduction to Web Development Java and the Web IA and the Enterprise November 26 28 Study Abroad Spend July in Madrid Informational meeting: Wednesday, November 28 3:00 pm in Room J-308 http://spsumadrid08.blogspot.com/ Notice: This session is being recorded. Copyright 2007 by Bob Brown Java Applets This is not a Java course! (You re supposed to know about Java.) Our goal is to learn when and how to use Java in Web Development, not how to write Java programs. public class myapplet extends JApplet { or applet There is More to Java than Applets Java is a programming language Java applets take advantage of a part of Java Applets are restricted by the browser For client-side. There are servlets for the server side. Advantages of Java Applets Good support for graphics Powerful programming language Large collection of classes This will be on the exam. Disadvantages of Java Applets Browser support (Microsoft vs. Sun Now getting better; but ask me about object support!) Speed Download time JVM execution Swing support is improving. This will be on the exam. 1

How Java Fits with the Web The browser: finds an applet (or object) reference in HTML downloads the applet calls init calls start (also on return to page) calls paintcomponent On leaving a page: calls stop Exiting browser: calls destroy paintcomponent paintcomponent: Is called by the browser, never directly Paints to a JPanel The JPanel is added to a content pane The 'Wel' Applet public class Wel extends JApplet { Container messagearea = getcontentpane(); MessagePanel mymessagepanel = new MessagePanel(); public void init() { messagearea.add(mymessagepanel); class MessagePanel extends JPanel { public void paintcomponent(graphics grafobj) { super.paintcomponent(grafobj); grafobj.drawstring("welcome!", 50, 50); Compiling Java The Java compiler is javac You run it from the command line or an IDE Assume you have created Wel.java with nano: javac Wel.java This will create Wel.class and MessagePanel.class provided there are no errors. Setting Font Properties Invoke the setfont method before drawstring Font font1 = new Font("TimesRoman", font.italic, 24); grafobj.setfont(font1); Connecting Java to HTML: Object The <object> tag can connect a Java applet to an HTML document. <object codetype="application/java" classid="java:wel.class" width="300" height="100"> </object> The <object> tag can be used with other things besides Java applets. 2

Connecting Java to HTML: Applet The <object> tag is not yet well-supported by browsers. <applet code="wel.class" width="300" height="100"> </applet> <applet> is deprecated. (But it works where <object> does not.) Why Not Use Object This works in IE6, Netscape, Mozilla, and Firefox. <applet code="wel.class" width="300" height="100"> Applets are not supported here! </applet> Text between tags is displayed if applets are not supported by the browser. One Form of the <object> Tag This works in Netscape, Mozilla, Firefox, but not IE6. <object codetype="application/java" classid="java:wel.class" width="300" height="100"> </object> The code with yellow background is used by the browser. 3

The code with yellow background is used by the browser. Supplying Parameters to Applets <applet... > <param name="size" value="24"> </applet> String mysize=getparameter("size"); Also do this with objects. Returns null if the parameter is not defined; Check for null and supply a default value (or error.) AWT Graphics Coordinate System Distances are pixels. 0,0 Increasing Y Increasing X The drawline Method public void paintcomponent(graphics grafobj){ grafobj.drawline(20,10,60,80); Other Methods of class Graphics drawrect(x,y,width,height); fillrect(x,y,width,height); drawroundrect(x,y,w,h,rh,rw); fillroundrect(x,y,w,h,rh,rw); draw3drect(x,y,w,h,state); drawoval(x1,y1,width,height); filloval(x1,y1,width,height); A 3D rectangle is like a button. State is a Boolean that tells whether it looks "pushed" or "unpushed." 4

Arrays of coordinates Number of coordinates Polygons int xcoord [] = {30,50,64,64,50,30,16,16,30; int ycoord [] = {10,10,24,44,58,58,44,24,10; grafobj.drawpolygon(xcoord,ycoord,9); Or, create an object of class Polygon; see pp. 280 282 Colors 24-Bit color available RGB values, 8 bits each or, named colors pp. 282-283. Color mycolor = new Color(r, g, b); Set background and foreground colors with methods of class Panel. Swing Widgets Similar to HTML forms controls; provide for interactivity. JLabel mylabel = new JLabel("Name:"); JButton mybutton = new JButton("Click me"); JCheckbox mybox1 = new JCheckbox("Milk"); JTextField custname = new JTextField(32); Swing Radio Buttons Create a button group Create buttons Add buttons to group ButtonGroup payment = new ButtonGroup(); JRadioButton btn1=new JRadioButton("Visa",true); JRadioButton btn2=new JRadioButton("MC",false); payment.add(btn1); payment.add(btn2); The Panel Again paintcomponent is not needed for Swing JPanels can be created in the applet public class Pizza extends JApplet{ Container contentpane = getcontentpane(); public void init() { JPanel mypanel = new JPanel();... Jlabel namelabel = new JLabel("Name:"); JTextField myname = new JTextField(30); mypanel.add(namelabel); mypanel.add(myname);... contentpane.add(mypanel); Colors Again JPanel has methods to set foreground and background colors. mypanel.setbackground(color.yellow); mypanel.setforeground(color.blue); 5

Inheritance Java is a true object-oriented language. Objects in a panel (generally) inherit the methods of the panel. So, this works: JTextField myname = new JTextField(30); mypanel.add(myname); myname.setforeground(color.red); Events and Event Handlers Control (widget) actions generate event objects Event listeners can be registered for event objects. Simple listeners can be anonymous classes btn1.addactionlistener(new ActionListener(){ public void actionperformed(actionevent e) { text.setfont(newfont); ); Example: pp. 290-292 Economies Don t Always Scale Information Architecture and the Enterprise Large organizations need: Consistent processes Clear and consistent communications The purpose of an organization is to coordinate the efforts of many people. However, technology drives decentralization. The Decentralizing Nature of Technology Compare and contrast: A personal Web site A corporate or university Web site Building a Web page is easy Everyone in the enterprise will want to do it They will all be different! 6

The Corporate Portal Model Problems Where to begin? Silos of information Same concept, different labels Different concept, same labels Inconsistent navigation systems Ignorance is not bliss! The cost of finding information The cost of not finding information Inconsistent information The Case for Centralization Increased Revenues Reduced Costs Clearer Communication Shared Expertise Centralization is Inevitable Anyway (?) 7

Roadblocks to Centralization Unrealistic Scheduling No Stone Unturned The Monolithic Effort Human Nature Ignored Insufficient Support A Framework for Centralization A New Business Unit Phasing In Strategy and Tactics A New Business Unit Establish, with support of senior management, a business unit for IA and content management. Become a service provider. Become self-supporting. Offer basic services free (For consultants, this is pitching. ) Bill for premium services. Billing limits demand. (Good.) A Phased Rollout You cannot do everything all at once. Identify the best clients Content Users Context You will have to sell your services! A client information checklist Projecting demand Strategy and Tactics Separate strategy and tactics Strategy Strategic alignment Financial and political stability Management and performance Tactics Implementing IA for clients Coming Attractions Monday: Other Media, Accessibility Intellectual Property Q and A Wednesday: Review for Final Term papers due Monday, December 10 Final exam 6:00 to 7:50 8

Questions 9