Java Quick & Dirty By Bert Wachsmuth. Overview  We will cover: What is Java Using and Writing Java applets Getting more information  We will need: Knowledge.

Slides:



Advertisements
Similar presentations
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Advertisements

Java Applet & JavaScript SNU OOPSLA Lab. October 2005.
Applets The objectives of this chapter are: To describe applets and their purpose To discuss embedding applets in HTML pages.
Programming and Problem Solving With Java Copyright 1999, James M. Slack Applets What is an Applet? Applet Parameters Graphics in Applets Other Applet.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Lecture 24 Applets. Introduction to Applets Applets should NOT have main method but rather init, stop, paint etc They should be run through javac compiler.
18-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Chapter 14 Applets. 2 Knowledge Goals Understand the differing roles of applications and applets Understand how a browser operates Understand the role.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
Applets. An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from a browser You.
26-Jun-15 Applets. 2 An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from.
28-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
1 CSC 551: Web Programming Spring 2004 Java Overview  Design goals & features  platform independence, portable, secure, simple, object-oriented, … 
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
Applets Java API.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Slides © Marty Hall, book © Sun Microsystems Press 1 Including Files & Applets in JSP Documents Core Servlets & JSP book:
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Applets CS 3331 Sections 3.3 & 4.7 of [Jia03].
JAVA APPLETS By: Ms. Humaira Siddiqui. Java and the Internet Java is considered to be a language well suited to be used in the internet. In contrast with.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
JAPPLET.
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
Java Applet Presented by: Feng Liu. Agenda Introduction Java Applet vs. JavaScript Steps in Creating a Java Applet Java Applet Example Do I have to write.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Chapter 8 Introduction to HTML and Applets Fundamentals of Java.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Chapter 13. Applets and HTML HTML Applets Computer Programming with JAVA.
POS 406 Java Technology And Beginning Java Code
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
Java Applets. An applet is a Panel that allows interaction with a Java program. A applet is typically embedded in a Web page and can be run from a browser.
Introduction to Java Applets Sangeetha Parthasarathy 05/21/2001.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Java Applets 1. What is an applet? An applet is a small Java program that is typically embedded in a Web page and can be run using the applet viewer or.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language) document containing.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 35 – Overview of Java Web Programming Webpage:
Applets Yong Choi School of Business CSU, Bakersfield.
Computing System Fundamentals 3.1 Language Translators.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
1 Applets. 2 Design of Applets 3 Sun wrote Java to be executable within a hosting application browser The applications are applets. An applet is downloaded.
Applets, Images, and Audio Chapter 14 CSCI CSCI 1302 – Applets, Images, and Audio2 Outline Introduction The Applet Class –The init Method –The start.
1 Applets. 2 What is an applet? Applet: a Java program that can be inserted into a web page and run by loading that page in a browser brings web pages.
CSI 3125, Preliminaries, page 1 Applet. CSI 3125, Preliminaries, page 2 Applet An applet is a Java program that runs in a Web browser. An applet can be.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
CHAPTER Agenda Applets Servelets Browsers HelloWorld.
1 Java Applet Basics Chapter Eight. 2 Applets vs. Applications l Applications: Stand alone Java programs run by interpreter l Applets WWW browser embedded.
Introduction to HTML Simple facts yet crucial to beginning of study in fundamentals of web page design!
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance –information hiding –classes: blueprints for objects Java Applets.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
Lecture 09 Applets.
Java Applet.
30 Java Applets.
Applets.
UNIT-5.
Java Applets.
Introduction to Applet, Application and JDK
CSC 551: Web Programming Spring 2004
Applet in Java.
CSC 551: Web Programming Spring 2004
Java Programming COMP-417 Applet
Introducing Java.
11.1 Applets & graphics.
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Enabling Application Delivery Via the Web
ITEC324 Principle of CS III
APPLET PROGRAMMING.
Presentation transcript:

Java Quick & Dirty By Bert Wachsmuth

Overview  We will cover: What is Java Using and Writing Java applets Getting more information  We will need: Knowledge of HTML and web page creation  We will get: Basic understanding of Java but we will NOT become the world’s foremost Java programmer

What is Java  Java is a programming language that: Is exclusively object oriented Has full GUI support Has full network support Is platform independent Executes stand-alone or “on-demand” in web browser as applets

Simple Example Web page with Java applet HTML code for above web page

Simple Example Java code for TickerApplet

Example Summary  To create a web page with an Applet you need: 1. A Java-aware web browser (usually beyond your control) 2. A web page including a special HTML tag called tag 3. One or more Java class files (produced separately from Java source code)

Using Java Applets  To use Java applets, you: Locate appropriate class file(s) Learn how to configure applet Embed the Applet into web page <applet codebase=“base_url” // if different from current directory code=“AppletName.class” // name of class file width=“###” // width of applet area height=“###”> // height of applet area // do not forget this

Simple Applets  TickerTape codebase: code: TickerApplet.class width: 300, height=30  3D Surface codebase: code: surface.class width: 500, height=550  Missile Defense codebase: code: MissileCommand.class width: 320, height: 200

Configurable Applets  Many applets can be configured using “param” tags: 1. Inquire about name and meaning of “param” tags for the applet 2. Add “param” tags to HTML as needed <applet codebase=“base_url” code=“AppletName.class” width=“###” height=“###”>...

Configurable Applet Examples  TickerTape codebase: code: TickerApplet.class width: 300, height=30 param: msg, delay, foreground, background  Chatterbox codebase: code: ChatterBoxlet.class width: 200, height=50 param: host (use sciris.shu.edu), port (use 1234)  Note: Applets can be embedded easily with FrontPage or Notes (LearningSpace)

Writing Java Applets To create Java Applets, you need: Knowledge and a good Java book Good ideas, patience, and persistence and A text editor & Java compiler or An “Integrated Developing Environment” (IDE)

Tools for Writing Java Applets Java API -> essential resource Editor ->Programmer’s File Editor Compiler -> SUN’s Java compiler IDE -> BlueJ version IDE -> Microsoft Visual J Available from SHU but not recommended

Writing Applets - Intro  Java Applets are saved as “Name.java”  They must be compiled into “Name.class”  They require HTML page to run  They have “fields” and “methods” fields are used to store data methods are used to perform action  They inherit *lots* of fields and methods from “parent” classes

Writing Applets - Framework import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Name extends Applet implement ActionListener { private type aField = new type(“foo”); public void init() { /* code here when applet is initialized */ } public void start() { /* code here to execute when page is visited */ } public void stop() { /* code here to execute when page is left */ } public void paint(Graphics g) { /* drawing code goes here */} public void actionPerformed(ActionEvent ae) { /* code to react to action events here */ } }

Writing Applets – Example 1 1.Open editor 2.Type this source code 3.Save as “Junk.java” 4.Compile into “Junk.class” 5.Create HTML document 6.Add proper tag 7.View in web browser Steps

Writing Applets – Example 2 1.Need two pictures named “picture1.jpg” and picture2.jpg” 2.Open editor 3.Type this source code 4.Save as “Slide.java” 5.Compile into “SSlide.class” 6.Create HTML document 7.Add proper tag 8.View in web browser Steps

Enhancing Applet 2 1.Modify previous source code 2.Save and compile 3.Add proper tag(s) to previous HTML document 4.View new applet in web browser (quit and restart) Steps What parameter tag(s) to use? What must image names be? How many images can be loaded? Questions :

Self-running Applet 1.Modify previous source code 2.Save and compile 3.View new applet in web browser (quit and restart) Steps What’s happening? What’s the delay? Pick a new tag! Does paint method change? Questions

A Professional Applet  To create a professional Applet: small, fast loading, preloading resources completely fool-proof completely configurable utilizes reusable components (objects) cool and new  Too much for this course

What’s the Object of Object- Oriented Programming? OOP revolves around 6 principles: Classes: Fundamental structure of every Java program (fields and methods) Objects: Are constructed from class blueprints Encapsulation: Regulate access to class members Overloading: Multiple definitions for methods Inheritance: Relationships between classes Polymorphism: To deal with related classes based on common features

OOP Example Our Task: Create a unit conversion applet that converts between feet and meter The program should execute in a separate window The program should have one menu item to exit Steps: Think about the objects to be used Download the files from the web site Compile, execute, test, and IMPROVE

Some “less-good” News  Java has “version problems” with applets: 1.0: Netscape 3, IE 3 1.1: Netscape < 4.5, IE 4 1.2: Netscape > 4.5, IE 4 1.3: Netscape 6 or “Java plugin”  Platform independent questionable (<1.3)  C++ “native” code is faster  No access to system-level programming  Large Programs need long download times  Applets have Security Restrictions (no saving…)

More Information  Sun’s Website & Online Tutorials  JARS Resources  Seton Hall Classes CSAS1111, CSAS1112, etc  Java by Definition  Books See Barnes & Nobles or Amazon.comAmazon.com

The End …

What is JavaScript  JavaScript is a programming language that: Is object-oriented but “loosely typed” Has no GUI support but supports most web page elements Is somewhat standardized and runs only inside a JavaScript-aware web browser Code is embedded directly in a web page Is a lot easier than Java  JavaScript Example: document.writeln(“Today is ” + (new Date()));