290 likes | 676 Views
G5BUID - Java Swing - 2005. 2. Timeline. 27th Oct (Now) - Java Necessaries, Swing Basics28th Oct - Components and Containers3rd Oct - Layout Management17th Nov - Event Handling and Listeners18th Nov - Graphics with Swing8th Nov
E N D
1. Java Swing - Lecture 1An Introduction Chris Coleman
(cqc@cs.nott.ac.uk)
http://www.cs.nott.ac.uk/~cqc/G5BUID
2. G5BUID - Java Swing - 2005 2 Timeline 27th Oct (Now) - Java Necessaries, Swing Basics
28th Oct - Components and Containers
3rd Oct - Layout Management
17th Nov - Event Handling and Listeners
18th Nov - Graphics with Swing
8th Nov Problem Class Session
Labs Start Week Beginning: 7th Nov. Time TBA.
3. G5BUID - Java Swing - 2005 3 Before we Start
(1) Swing is all Java.
You must know about, and understand:
Classes / Objects
Method Overloading
Inheritance
Polymorphism
Interfaces
How to read the Java2 API Documents
4. G5BUID - Java Swing - 2005 4 Before We Start
(2) If Java is a problem learn NOW, not in a month when the coursework is due!
Labs
Come to the labs and help is there for both Java and Swing.
Web
Use the Sun/Java tutorials
Plenty of web resources out there, even the PRG notes
Read a book?
5. G5BUID - Java Swing - 2005 5 2D interface programming toolkits Tcl/Tk
Motif/UIL
IDEs (e.g. VB, MSVC++/MFC)
Java AWT the beginnings
Java JFC Swing (Java2 - JDK >= 1.2)
JBuilder and other Java IDEs
etc
6. G5BUID - Java Swing - 2005 6 What is Swing? A part of The Java Foundation Classes
Swing
Look and feel
Accessibility
Java 2D (Java 2 onwards)
Drag and Drop
etc
Can be used to build Standalone Apps as well as Servlets and Applets
7. G5BUID - Java Swing - 2005 7 On-line reading and reference The Swing connection - http://java.sun.com/products/jfc/tsc/
The JFC Swing trail - http://java.sun.com/docs/books/tutorial/uiswing/
Fundamentals of JFC/Swing I & II - http://developer.java.sun.com/developer/onlineTraining/
8. G5BUID - Java Swing - 2005 8 Books Java Swing (1998), Robert Eckstein, Mark Loy, Dave Wood, O'Reilly
JFC Swing Tutorial, The: A Guide to Constructing GUIs, 2nd Edition (2004); K. Walrath and M. Campione, Addison Wesley
9. G5BUID - Java Swing - 2005 9 Getting started with Swing (1) Compiling & running programs
Swing is standard in Java 2 (JDK >= 1.2)
Use:
javac <program.java> && java <program>
Or JCreator / IDE
10. G5BUID - Java Swing - 2005 10 Getting started with Swing (2) Computer Science Department Stuff
PCs
Java 2 (1.5.0) on hard disk at \cs\java
Unix (tuck and much):
Java 2 (1.4.2) in /usr/bin (or /usr/java)
Differences between previous versions
http://java.sun.com/j2se/1.4.2/docs/guide/swing/SwingChanges.html
http://java.sun.com/j2se/1.5.0/docs/guide/swing/SwingChanges.html
Coursework marked on Win XP & JDK 1.5.0
11. G5BUID - Java Swing - 2005 11 Getting started with Swing (3) Swing, like the rest of the Java API is subdivided into packages:
javax.swing, javax.accessibility, javax.swing.border
At the start of your code - always
import javax.swing;
import javax.swing.event;
Most Swing programs also need
import java.awt.*;
import java.awt.event.*;
12. G5BUID - Java Swing - 2005 12 Differences between Swing and AWT (1) Never mix Swing and AWT components
If you know AWT, put J in front of everything
AWT: Button
Swing: JButton
Swing does all that AWT does, but better and theres much more of it.
13. G5BUID - Java Swing - 2005 13 Differences between Swing and AWT (2) Buttons and labels can display images
Behaviour and appearance of components
Component shape
Borders
Assistive technologies
Look and feel of the programs GUI
Windows (but only on Windows, M$ issues
.)
UNIX
GTK
etc
14. G5BUID - Java Swing - 2005 14 A typical Swing program Consists of multiple parts
Containers
Components
Events
Graphics
(Threads)
Now look at each in turn
15. G5BUID - Java Swing - 2005 15 A simple Swing program - Containers Containers