Introduction to Advanced Java - WordPress.com

wakecabbagepatchSoftware and s/w Development

Nov 18, 2013 (3 years and 4 months ago)

67 views



Java

Advanced
Programming




Explain the term object
-
oriented programming


Explain the concepts of classes, objects, properties,
methods and events


List and describe the three steps for writing a Java
projects


Identify the elements of the
NetBeans

environment


Define design time, run time and break time


Write, run, save, modify your first Java project


Identify syntax errors, run
-
time errors and logic
errors

Introduction to GUI in Java




Microsoft Windows uses GUI


Windows GUI defines how the various elements
look and function


Create new windows, called
forms
.


Use the toolbox to add the various elements called
controls
.


Projects written follow a programming technique
called
OOP
.

The Windows GUI




Procedural languages


the program specifies the exact
sequence of all operations


-
program logic determines the next instruction to

execute in response to conditions & user request

e.g.


BASIC, C, COBOL, FORTRAN, PL/I & Pascal


OOP languages


program are no longer procedural


-

do not follow a sequential logic


-

user can press keys & click various buttons &

boxes in a window

e.g.


VB.NET, C# & Java

Programming Languages
-

Procedural,
Event Driven, & Object Oriented




Will work with objects which have properties,
methods and events


Each object is based on a class


1.
Objects

2.
Properties

3.
Methods

4.
Events

5.
C
lasses

The Object Model



1.
Objects


e.g.


forms


windows and dialog boxes you place on



the screen


controls


components you place inside a form,


such
as text boxes, buttons and list
boxes


2.
Properties


tell something about or control the

behavior of an object such as its name, color, size

or location


The Object
Model
(cont.)



3.
Methods


Actions associated with objects are called
methods
.


Methods are the verbs of object
-
oriented
programming.


4.
Events


An event occurs when the user takes an action such as
clicking a button, pressing a key or closing a window


Events also can be triggered by actions of other objects


The Object Model
(cont.)



5.
Classes


A class is a template or blueprint used to create a new
object.


Classes contain the definition of all available
properties, methods and events.


Each time you create a new object it must be based on
a class.


The Object Model
(cont.)





3 steps for planning the project


Repeat the process for creating the project

1.
Setting up the user interface

2.
Defining the properties

3.
Creating the code

Writing Java Projects




IDE
-

Integrated Development Environment



-

consists of various tools, including the
ff
:


F
orm designer


E
ditor


C
ompiler


Debugger


Object browser


Help facility

The
NetBeans

Environment




IDE Start Page




New Project Dialog




IDE Main Window




Document window


largest window in the center of
the screen


Form designer


where you design a form that
makes up your user interface


Properties window


set the properties for the objects
in your project


Toolbox


holds the tools you use to place controls
on a form


Help


includes the entire reference manual as well
as many coding examples




While you are designing the user interface and
writing code, you are in
design time.



When you are testing and running your project you
are in
run time
.



If you get a run
-
time error or pause project
execution, you are in
break time
.




Writing your first Java Project



Object Class

Example

Form

dataEnrtyForm

Button

exitButton

TextField

paymentAmountTextField

Label

totalLabel

Radio button

boldRadioButton

CheckBox

printSummaryCheckBox

comboBox

bookListComboBox

ListBox

ingredientsListBox

Recommended Naming Conventions




Syntax errors


When you break a rules for punctuation, format or
spelling you generate syntax error.


Run
-
time errors


If your project halts during execution, it is called a
run
-
time error or an exception.


Statements that cannot execute correctly cause run
-
time errors.


Logic errors


Your project runs but produces incorrect results

Finding & Fixing Errors