1 / 15

Early GUIs with Java

Early GUIs with Java. As presented in Java: Complete Course in Programming and Problem Solving by Lambert and Osborne. Advantages of Early GUIs. Realistic GUIs are fun to create and generate student enthusiasm Students are accustomed to using GUI-based programs

Download Presentation

Early GUIs with Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EarlyGUIs with Java As presented in Java: Complete Course in Programming and Problem Solving by Lambert and Osborne

  2. Advantages 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

  3. But . . . • 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

  4. Abstraction to the Rescue • We use Java’s power of abstraction to simplify GUI creation • We call the result BreezyGUI

  5. A Simple Program Using BreezyGUI The user enters the radius in the upper field and selects the Compute button. Code on next slide.

  6. import 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

  7. Transition 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 Java’s AWT • and the book shows one how to make the transition

  8. BreezyGUI Highlights Supports • applications, applets, and dialogs • common window components • drop down menus • mouse events And it’s actually easier to use than terminal I/O

  9. BreezyGUI 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

  10. And Now for Some Examples taken from Java: Complete Course in Programming and Problem Solving

  11. Compute Sales Commissions

  12. Navigate and Maintain an Array of Student Objects

  13. Drag Circles

  14. Analyze a Text File

  15. A Color Meter

More Related