Title: Early GUIs with Java
1EarlyGUIs with Java
- As presented in
- Java Complete Course in
- Programming and Problem Solving
- by Lambert and Osborne
2Advantages of Early GUIs
- Realistic GUIs are fun to create and generate
student enthusiasm - Students are accustomed to using GUI-based
programs - User interface design is an important part of
program development
3But . . .
- GUIs are too hard to create in Java
- The abstract windowing toolkit (AWT) is too
complicated - So doing GUIs would distract from core
programming concepts
4Abstraction to the Rescue
- We use Javas power of abstraction to simplify
GUI creation - We call the result BreezyGUI
5A Simple Program Using BreezyGUI
The user enters the radius in the upper field and
selects the Compute button.
Code on next slide.
6import java.awt. import BreezyGUI. public
class CircleArea extends GBFrame Label
radiusLabel addLabel ("Radius",1,1,1,1)
DoubleField radiusField addDoubleField
(0,1,2,1,1) Label areaLabel
addLabel ("Area",2,1,1,1)
DoubleField areaField addDoubleField
(0,2,2,1,1) Button computeButton
addButton ("Compute",3,1,2,1)
public void buttonClicked (Button buttonObj)
double radius, area radius
radiusField.getNumber() area 3.14
radius radius areaField.setNumber
(area) areaField.setPrecision (2)
public static void main (String args)
Frame frm new CircleArea() frm.setSize
(200, 150) frm.setVisible
(true)
Lay out the GUI objects
Handle the user events
Open the window and start the program
7Transition to Full AWT Is Easy
- Students are now familiar with
- structure of event driven programs
- behavior of basic window components
- designing GUI based applications
- In addition
- BreezyGUI is an extension of Javas AWT
- and the book shows one how to make the transition
8BreezyGUI Highlights
- Supports
- applications, applets, and dialogs
- common window components
- drop down menus
- mouse events
- And its actually easier to use than terminal I/O
9BreezyGUI in Many Courses
- Has been used in CS0, CS1, CS2, and more advanced
courses - Useful in any course where direct use of AWT is
not required
10And Now for Some Examples
taken from Java Complete Course in Programming
and Problem Solving
11Compute Sales Commissions
12Navigate and Maintain an Array of Student Objects
13Drag Circles
14Analyze a Text File
15A Color Meter