Java Quick - PowerPoint PPT Presentation

About This Presentation
Title:

Java Quick

Description:

See Barnes & Nobles or Amazon.com. The End ... What is. JavaScript ... Is somewhat standardized and runs only inside a JavaScript-aware web browser ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 26
Provided by: shu1
Learn more at: http://pirate.shu.edu
Category:
Tags: and | barnes | java | nobles | quick

less

Transcript and Presenter's Notes

Title: Java Quick


1
JavaQuick Dirty
  • By Bert Wachsmuth

2
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 willNOT
    become the worlds foremost Java programmer

3
What isJava
  • 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

4
Simple Example
Web page with Java applet
HTML code for above web page
5
Simple Example
Java code for TickerApplet
6
Example Summary
  • To create a web page with an Applet you need
  • A Java-aware web browser (usually beyond your
    control)
  • A web page including a special HTML tag called
    ltAPPLETgt tag
  • One or more Java class files (produced separately
    from Java source code)

7
Using JavaApplets
  • To use Java applets, you
  • Locate appropriate class file(s)
  • Learn how to configure applet
  • Embed the Applet into web page
  • ltapplet codebasebase_url // if different
    from current directory
  • codeAppletName.class // name of class
    file
  • width // width of
    applet area
  • heightgt // height of
    applet area
  • lt/appletgt // do not forget
    this

8
Simple Applets
  • TickerTape
  • codebase http//pirate.shu.edu/wachsmut/Ticker
    code TickerApplet.classwidth 300, height30
  • 3D Surface
  • codebase http//pirate.shu.edu/wachsmut/Surface
    code surface.classwidth 500, height550
  • Missile Defense
  • codebase http//www.csd.uu.se/d95vil/missile/cl
    assescode MissileCommand.classwidth 320,
    height 200

9
Configurable Applets
  • Many applets can be configured using param
    tags
  • Inquire about name and meaning of param tags
    for the applet
  • Add param tags to HTML as needed
  • ltapplet codebasebase_url
    codeAppletName.class
  • width
  • heightgt ltparam nameName
    valueValuegt ltparam nameName2
    valueValue2gt ...lt/appletgt

10
Configurable Applet Examples
  • TickerTape
  • codebase http//pirate.shu.edu/wachsmut/Ticker
    code TickerApplet.classwidth 300,
    height30param msg, delay, foreground,
    background
  • Chatterbox
  • codebase http//sciris.shu.edu/Java/Chatcode
    ChatterBoxlet.classwidth 200, height50param
    host (use sciris.shu.edu), port (use 1234)
  • Note Applets can be embedded easily with
    FrontPage or Notes (LearningSpace)

11
WritingJava 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)

12
Tools for WritingJava Applets
  • Java API -gt essential resource
  • http//mathcs.shu.edu/Resources/Java/API/
  • Editor -gtProgrammers File Editor
  • http//www.lancs.ac.uk/people/cpaap/pfe/
  • Compiler -gt SUNs Java compiler
  • http//www.javasoft.com/
  • IDE -gt BlueJ version 1.1
  • http//bluej.monash.edu/
  • IDE -gt Microsoft Visual J 6.0
  • Available from SHU but not recommended

13
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

14
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 /

15
Writing Applets Example 1
Steps
  • Open editor
  • Type this source code
  • Save as Junk.java
  • Compile into Junk.class
  • Create HTML document
  • Add proper ltappletgt tag
  • View in web browser

16
Writing Applets Example 2
Steps
  • Need two pictures namedpicture1.jpg and
    picture2.jpg
  • Open editor
  • Type this source code
  • Save as Slide.java
  • Compile into SSlide.class
  • Create HTML document
  • Add proper ltappletgt tag
  • View in web browser

17
Enhancing Applet 2
Steps
  • Modify previous source code
  • Save and compile
  • Add proper ltparamgt tag(s) to previous HTML
    document
  • View new applet in web browser (quit and restart)

Questions
  • What parameter tag(s) to use?
  • What must image names be?
  • How many images can be loaded?

18
Self-runningApplet
Steps
  • Modify previous source code
  • Save and compile
  • View new applet in web browser (quit and restart)

Questions
  • Whats happening?
  • Whats the delay?
  • Pick a new ltparamgt tag!
  • Does paint method change?

19
A ProfessionalApplet
  • 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

20
Whats 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

21
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

22
Some less-good News
  • Java has version problems with applets
  • 1.0 Netscape 3, IE 3
  • 1.1 Netscape lt 4.5, IE 4
  • 1.2 Netscape gt 4.5, IE 4
  • 1.3 Netscape 6 or Java plugin
  • Platform independent questionable (lt1.3)
  • C native code is faster
  • No access to system-level programming
  • Large Programs need long download times
  • Applets have Security Restrictions (no saving)

23
More Information
  • Suns Website Online Tutorials
  • http//www.javasoft.com/
  • JARS Resources
  • http//www.jars.com/
  • Seton Hall Classes
  • CSAS1111, CSAS1112, etc
  • Java by Definition
  • http//pirate.shu.edu/wachsmut/jbd/
  • Books
  • See Barnes Nobles or Amazon.com

24
The End
25
What isJavaScript
  • 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
  • ltscript languageJavaScriptgt
  • document.writeln(Today is (new Date()))
  • lt/scriptgt
Write a Comment
User Comments (0)
About PowerShow.com