Title: CS242 Advanced Programming Concepts in Java
1CS242Advanced Programming Concepts in Java
Prof. Searleman jets_at_clarkson.edu
2Announcements
- Career Fair!
- Greg Lacey from IBM will talk on software
development Thurs., 400, SC162 - Also check out Johnson Johnson, PAR, GE, and
many more - Demetrios Dimatos will talk to our class today
about his experience as a Java developer at IBM
Silicon Valley
a horrible death to die
3Outline
- Graphical User Interfaces (GUIs)
- Java Foundation Classes (JFC) Swing
- Read the SUN Tutorial
- Constructing a GUI with JFC/Swing
- (http//java.sun.com/docs/books/tutorial/uiswing/
index.html) - return and discuss HW1
- HW1 and HW2 can be resubmitted by next Tuesday
- HW3 will be posted today due next Thursday
4Common errors
- missing source file comment
- javadoc comments
- not in correct location (so wont appear)
- reveals implementation details
- doesnt describe the object being modelled
- use constants instead of hard-coding numbers
- misuse of a class variable
- public, private, package, protected misused
- initializes to a meaningless number (e.g. 0, -1)
- inadequate testing
- source file not in afs
5Whats the problem?
public class Die() Random rng public int
TopSide // other stuff
6Whats the problem?
public class Die() private static Random
rng private int topSide public Die()
rng new Random() topSide
rng.nextInt(5) 1 // other stuff
7Whats the problem?
public class Die() private static Random
rng private int topSide private final int
DefaultSIDES 6 public Die() rng
new Random() topSide rng.nextInt(DefaultS
IDES) 1 public int roll()
rng new Random() topSide
rng.nextInt(DefaultSIDES) 1 return
topSide
8How to resubmit an assignment
- Make a new subdirectory in your afs directory
(e.g. hw1r) - upload your new source files and test runs
- turn in BOTH the original printout with the grade
sheet attached and the new printout
9JFC
- AWT (Abstract Window Toolkit)
- java.awt. and java.awt.event.
- Swing
- javax.swing. and javax.swing.event.
- Accessibility, 2D API, Drag Drop
10Swing
- consistent user experience across platforms
(written in Java, peerless) - pluggable look feel (PLAF)
- (Windows, Metal, Motif LFs builtin)
- Model-View-Controller (MVC) Framework
11Swing API
- javax.swing
- javax.swing.event
- other Swing packages include
- javax.accessibility, javax.swing.border
- javax.swing.colorchooser,
- javax.swing.filechooser, javax.swing.plaf
- javax.swing.table, javax.swing.text
- javax.swing.text.html, javax.swing.text.rtf
- javax.swing.tree, javax.swing.undo
12Lightweight Components
- AWT heavyweight components
- Frame --- peer with ? native window
- Button --- peer with ? native button
- Swing lightweight components
- components are not dependent on native peers to
render themselves use simplified graphics
primitives to paint themselves on the screen
13(No Transcript)
14Model-View-Controller MVC Architecture
- Model The core of the application. This
maintains the state and data that the application
represents. When significant changes occur in the
model, it updates all of its views - Controller The user interface presented to the
user to manipulate the application. - View The user interface which displays
information about the model to the user. Any
object that needs information about the model
needs to be a registered view with the model.
15(No Transcript)
16Look Feel
Java LF (Metal)
GTK LF (Motif)
Mac OS LF
Windows LF