» The thief and house program we used last time is refactored to follow the MVC pattern » Now it consists of four parts: ˃AScene (model) ˃AThiefController.

Slides:



Advertisements
Similar presentations
1 Event Listeners Some Events and Their Associated Event Listeners Act that Results in the EventListener Type User clicks a button, presses Enter while.
Advertisements

Introduction to Java 2 Programming
Java Graphical User Interface (GUI) using Visual Editor in eclipse CSI 1390 – Java Programming Instructor: Saeid Nourian University.
Made with love, by Zachary Langley Applets The Graphics Presentation.
Programming in Java; Instructor:John Punin Graphics and Graphical User Interfaces1 Programming in Java Graphics and Graphical User Interfaces.
Mouse Listeners We continue our examination of GUIs by looking at how to interact with the mouse –Just as Java creates Events when the user interacts with.
Bar Graph Design. Left-side/Right-side mechanical processing creative, abstract reasoning.
JFrame JComponent JFrame JComponent JFrame JComponent.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
CS 178: Programming with Multimedia Objects Aditya P. Mathur Professor of Computer Sciences Purdue University, West Lafayette Sept 9, 2004 Last update:
Event Handling Events and Listeners Timers and Animation.
Lecture 24 Applets. Introduction to Applets Applets should NOT have main method but rather init, stop, paint etc They should be run through javac compiler.
Unit 12 Object-oriented programming: Event-driven programming for GUI Jin Sa.
Building Memory… Day 7 – April 18, Mouse Listener Attached listeners to each card (but the back image only) When click event is generated, simply.
© The McGraw-Hill Companies, 2006 Chapter 10 Graphics and event- driven programs.
Object-Oriented Analysis and Design
Programming Task: Task 1 Controlled Assessment Practice.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
Computer Science and Engineering Department VI I - SEMESTER Subject Name : MIDDLEWARE TECHNOLOGIES LABORATORY Subject Code : IT-404.
7/3/00SEM107- © Kamin & ReddyClass 11 - Events - 1 Class 11 - Events r A couple of odds & ends m Component sizes  switch statement r Event types r Catching.
Previous programs used a JLabel for OUTPUT. Another Swing component that can be used for both user input and output is the JTextfield. Suppose we want.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many others 1.
MSc Workshop - © S. Kamin, U.Reddy Lect 4 - Events - 1 Lecture 4 – Event Handling r Painting r Event types r Catching different event types.
Concurrent Programming and Threads Threads Blocking a User Interface.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Java Programming Applets. Topics Write an HTML document to host an applet Understand simple applets Use Labels with simple AWT applets Write a simple.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
CPS 108/ola.1 From XP to javax.swing.* l What parts of embracing change can we embrace in 108?  Evolutionary design, small releases, iterative enhancement.
Java Direct Manipulation Chris North cs3724: HCI.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Event-Driven Programming 1.
Click the mouse to continue. Using styles A style is a saved collection of formatting, such as a font, font size, pattern, and alignment, that you can.
Mouse Listeners Moving the mouse will also generate events like the Timer –To have your program respond, you must implement either or both of MouseListener.
Review_6 AWT, Swing, ActionListener, and Graphics.
CS Lecture 04 Mice Lynda Thomas
1/18H212Mouse and Timer Events H212 Introduction to Software Systems Honors Lecture #16: Mouse and Timer Events October 26, 2015.
Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit7: Event-driven programming 1.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
CSC 205 Programming II Lecture 5 AWT - I.
Events and Event Handling
Responding to Events Event Handling in Java
A First Look at GUI Applications
Lecture 09 Applets.
Java GUI.
Click the mouse button or press the Space Bar to display the answers.
Review: Java GUI Programming
Java FX.
Architectural Patterns for Interactive Software
Ellen Walker Hiram College
MVC Paradigm The MVC paradigm breaks applications or interfaces into three parts: the model, the view, and the controller. A --> 25 % B --> 60 % C -->
Event-driven programming for GUI
Design Patterns in Swing and AWT
Design Patterns in Swing and AWT
Introduction to Computing Using Java
CT1514 Flash -3.
Properties and Collections
First select the DO HOMEWORK button
Model, View, Controller design pattern
Reflections on the Coordinate Plane
Presentation transcript:

» The thief and house program we used last time is refactored to follow the MVC pattern » Now it consists of four parts: ˃AScene (model) ˃AThiefController (controller 1) ˃AThiefMouseController (controller 2) ˃ASceneView (view) Note that at this point we do not use objectEditor to display the scene.

» View uses Java. awt to draw lines, images, or texts. » View extends Component. » The second property of view, BasicStroke dotted, determines the style of the output » Pay attention to the paint() method and different draw() method and their relations. » Notice that the view is an observer of the scene, so that it can update any change in the scene. » repaint() method call in propertyChange will draw the whole scene again.

» The button just move the thief to the right. » Notice that the button object is not the same thing as the button controller. You need to manually set the button controller as the action listener of the button. So the controller also implements ActionListener. » Once the button is pressed, it automatically call the actionPerformed() method to move the thief

» The mouse controller moves the thief to where the mouse click in the view. » aView.addMouseListener(this); This line enable the controller to listen to the mouse event in the view. As a Component, view naturally support addMouseListener() method. » There are a couple of different mouse events available. This program just uses mouse click event. » The event e, which is the argument of the method, contains information of the event. For example, in this program use it to retrieve the position of click.