Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSSE221: Software Dev. Honors Day 9 Announcements Announcements HW3 passed back, follow link from HW3 to its solution. HW3 passed back, follow link from.

Similar presentations


Presentation on theme: "CSSE221: Software Dev. Honors Day 9 Announcements Announcements HW3 passed back, follow link from HW3 to its solution. HW3 passed back, follow link from."— Presentation transcript:

1 CSSE221: Software Dev. Honors Day 9 Announcements Announcements HW3 passed back, follow link from HW3 to its solution. HW3 passed back, follow link from HW3 to its solution. Questions on GUIs? Questions on GUIs? No baby yet… No baby yet…

2 Capsule Deliverables Please email the quiz, key, and summary to me by 7:30 am on the day you are presenting. Please email the quiz, key, and summary to me by 7:30 am on the day you are presenting. Send.doc files Send.doc files (If you get them to me by 3pm on a weekday before you present, I’ll still print them) (If you get them to me by 3pm on a weekday before you present, I’ll still print them) Lessons from week 1: Lessons from week 1: Nice research and summarization! Nice research and summarization! Proofread your stuff. Everyone else will see it. Proofread your stuff. Everyone else will see it. 1-page quizzes are good (or staple) 1-page quizzes are good (or staple) Summaries don’t have to be verbose, just dense with info. Summaries don’t have to be verbose, just dense with info.

3 This week: Fifteen assignment Monday: Monday: GUIs using Java’s Swing library GUIs using Java’s Swing library Tuesday: Tuesday: Fifteen specification Fifteen specification EventListeners: responding to user input EventListeners: responding to user input Intro to UML as a design tool Intro to UML as a design tool Time to work on project Time to work on project Thursday: Thursday: Anonymous classes (capsule) Anonymous classes (capsule) Function objects and comparators (capsule) Function objects and comparators (capsule)

4 “Fifteen” Questions on Specification?

5 Fifteen Teams beltonj1-fishmad bennetrn-leveyjr bennindp-speyerea crockeea-morrisps devorejd-priestjs lundgrpb-skilessa johnsoad-smithny sullivja-wentztj mcginnda behlinmc-bennetdj clutecc-dovalojd gatesds heinma1-hulettbh johnsoac-rubinza kruthar-richarme millerbe-eckertwm mosttw-reillytm nibertjw-stokese Repos is csse221-200810- -. If solo, use your personal repos. Discuss how to pair-program

6 Event-driven Programming: What? We want our program to respond to events We want our program to respond to events Mouse motion, mouse clicks, button presses, menu selections, … Mouse motion, mouse clicks, button presses, menu selections, … The Java window manager generates a huge number of events The Java window manager generates a huge number of events Whenever any of these happen Whenever any of these happen We need to listen for specific events We need to listen for specific events class Foo implements MouseListener { … }

7 Event-driven Programming: How? Implement the BlahListener interface Implement the BlahListener interface class Foo implements MouseMotionListener { … // We promise to implement these. void mouseDragged(MouseEvent e) { mouseDraggedMouseEventmouseDraggedMouseEvent System.out.println(“Hey, stop pulling me!”); } void mouseMoved(MouseEvent e) { System.out.println(“The mouse is moving!”); mouseMovedMouseEventmouseMovedMouseEvent System.out.println(e.getX() + “ “ + e.getY()); }}

8 Event-driven Programming: Which? Interface, that is… MouseMotionListener MouseMotionListener For receiving mouse motion events (movement and dragging) on a component. For receiving mouse motion events (movement and dragging) on a component. MouseListener MouseListener For clicks and other mouse events (click and double-click, mouse enters component) For clicks and other mouse events (click and double-click, mouse enters component) ActionListener ActionListener For component-defined actions (such as pressing a button) For component-defined actions (such as pressing a button) KeyboardListener KeyboardListener ChangeListener ChangeListener For components in which we only care about change (like sliders) For components in which we only care about change (like sliders) See the API spec. for which methods you need to write

9 Listeners Need 3 things! Need 3 things! 1. Responder implements ActionListener interface 2. This means it implements actionPerformed method: public void actionPerformed(ActionEvent e) { // what happens when button is pressed } 3. The responder must add the listener: Say a frame has a button. this.button.addActionListener(this); Listens Responds (this is the frame, but could be a panel or even the button itself)

10 E.g. Button in a Panel Button is the event source Button is the event source Panel has to respond to the event and therefore must listen for events. Panel has to respond to the event and therefore must listen for events. public TopPanel extends JPanel implements ActionListener { private JButton changeColor; private JButton changeColor; … public TopPanel(){ public TopPanel(){ this.changeColor = new JButton(“Click to change color”); this.changeColor = new JButton(“Click to change color”); this.changeColor.addActionListener(this); //Add the listener to the source this.changeColor.addActionListener(this); //Add the listener to the source this.add(changeColor); this.add(changeColor); } public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){ //Change the background color of the panel //Change the background color of the panel }}

11 Do I have to write a whole separate class in its own file, just for an actionPerformed method? No! You could use an anonymous class or a function object No! You could use an anonymous class or a function object More on those next class More on those next class Funny that that’s the ordering of topics… Funny that that’s the ordering of topics…

12 Finish demo together Draw the UML for all classes so far Draw the UML for all classes so far Add the listeners. Add the listeners. What other connections do I need? What other connections do I need? Look at its Iterative Enhancement Plan together Look at its Iterative Enhancement Plan together Code Code Sliders are similar, I used the Java Swing Tutorial for some ideas. Sliders are similar, I used the Java Swing Tutorial for some ideas.

13 Start Fifteen Spec now You need to do 2 things before you start coding: You need to do 2 things before you start coding: Show us your UML Show us your UML Show us your Iterative Enhancement Plan Show us your Iterative Enhancement Plan

14 UML ideas List of components List of components For each component For each component Extends a class? Extends a class? Implements interfaces? Implements interfaces? Creates instances of other components? Creates instances of other components? Has instances of other components? Has instances of other components? For which objects can I use the default Java version and which do I need to extend? For which objects can I use the default Java version and which do I need to extend? Frames, panels: extend Frames, panels: extend Text boxes: use Java’s Text boxes: use Java’s Buttons: it depends Buttons: it depends Do now with another team (so groups of 4) on a whiteboard. Do now with another team (so groups of 4) on a whiteboard.

15 Iterative enhancement plan Such a plan ensures that you always have code that works Such a plan ensures that you always have code that works Each stage must be testable by running the application Each stage must be testable by running the application No looking at code! No looking at code! So “implement the Dud class” is NOT part of an iterative enhancement plan So “implement the Dud class” is NOT part of an iterative enhancement plan It is OK for some stages to include throw-away code It is OK for some stages to include throw-away code The stages should be about the same size/difficulty The stages should be about the same size/difficulty Iterative enhancement plan: A series of stages (and substages) by which to develop the application, with each stage testable by running the application


Download ppt "CSSE221: Software Dev. Honors Day 9 Announcements Announcements HW3 passed back, follow link from HW3 to its solution. HW3 passed back, follow link from."

Similar presentations


Ads by Google