Beruflich Dokumente
Kultur Dokumente
Learn Java
(GUI Applications)
PO Box 28234
Seattle, WA 98118
(206) 721-2556
FAX (508) 464-0455
E-Mail: support@kidwaresoftware.com
Web Site: www.kidwaresoftware.com
ii
Notice
These notes were developed for the course, Learn
Java (GUI Applications). They are not intended to be
a complete reference to Java. Consult other texts and
various websites for more detailed information.
The notes refer to several software and hardware
products by their trade names. These references are
for informational purposes only and all trademarks are
the property of their respective companies.
Lou Tylee
Seattle, Washington
January 2004
Contents
iii
Learn Java
(GUI Applications)
Contents
1.
Introduction to Java
Preview........................................................................................................1-1
Course Objectives.......................................................................................1-2
What is Java?..............................................................................................1-3
What is a GUI Application?.........................................................................1-4
A Brief Look at Object-Oriented Programming (OOP)................................1-6
What is Needed to Learn Java?.................................................................1-7
Downloading and Installing Java................................................................1-8
Downloading and Installing JCreator........................................................1-10
Testing the Installation..............................................................................1-12
Getting Help with a Java Program............................................................1-18
Structure of a Java Program.....................................................................1-19
Structure of a Java GUI Application..........................................................1-20
Swing Controls..........................................................................................1-22
Creating a Java Project with JCreator......................................................1-25
Create a Frame.........................................................................................1-31
Saving Java Projects with JCreator..........................................................1-34
JCreator and Java Files............................................................................1-35
Create the User Interface..........................................................................1-36
Example 1-1: Stopwatch Application - Adding Controls...........................1-40
Adding Event Methods..............................................................................1-46
Variables....................................................................................................1-50
Java Data Types.......................................................................................1-51
Variable Declaration..................................................................................1-53
Arrays........................................................................................................1-54
Constants..................................................................................................1-55
Variable Initialization.................................................................................1-56
Example 1-2: Stopwatch Application - Writing Code................................1-57
iv
1.
Contents
2.
vi
3.
Contents
4.
vii
viii
5.
Contents
6.
ix
x
7.
Contents
8.
xi
xii
9.
Contents
xiii
xiv