CoSc Lab # 5 (The Controller)

Similar documents
CoSc Lab # 6 (The Model) Due Date: Part I, Experiment classtime, Tuesday, Nov 6 th, 2018.

CoSc Lab # 8 (an array of a class) Due Date: Part I, Experiment classtime, Tuesday, Dec 4 th, 2018.

To gain experience using GUI components and listeners.

Page 1 of 7. public class EmployeeAryAppletEx extends JApplet

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Swing. By Iqtidar Ali

Graphical User Interface (GUI)

EVENTS, EVENT SOURCES AND LISTENERS

Chapter 12 Advanced GUIs and Graphics

CS 170 Java Programming 1. Week 9: Learning about Loops

Introduction. Introduction

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

CS111: PROGRAMMING LANGUAGE II

What Is an Event? Some event handler. ActionEvent. actionperformed(actionevent e) { }

CSC 1214: Object-Oriented Programming

12/22/11. Copyright by Pearson Education, Inc. All Rights Reserved.

CSE 1325 Project Description

Graphical User Interfaces. Comp 152

10403 Lab and Eclipse Introduction (Last updated by asanchez, jcomer 1/18/18)

Part 3: Graphical User Interface (GUI) & Java Applets

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Chapter 17 Creating User Interfaces

We are on the GUI fast track path

Graphic User Interfaces. - GUI concepts - Swing - AWT

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Blackboard Learn 9.1 Reference Terminology elearning Blackboard Learn 9.1 for Faculty

8. Polymorphism and Inheritance

CS 209 Programming in Java #13 Multimedia

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have)

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

TTTK Program Design and Problem Solving Tutorial 3 (GUI & Event Handlings)

Java IDE Programming-I

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

Model-View Controller IAT351

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

Chapter 13 Lab Advanced GUI Applications

be able to read, understand, and modify a program written by someone else utilize the Java Swing classes to implement a GUI

Introduction to the JAVA UI classes Advanced HCI IAT351

10/16/2008. CSG 170 Round 5. Prof. Timothy Bickmore. User Analysis Task Analysis (6) Problem Scenarios (3)

DEMYSTIFYING PROGRAMMING: CHAPTER FOUR

CS180 Recitation. More about Objects and Methods

AP CS Unit 11: Graphics and Events

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Systems Programming Graphical User Interfaces

CS 134 Programming Exercise 7:

Human-Computer Interaction IS4300

Object-Oriented Programming: Revision. Revision / Graphics / Subversion. Ewan Klein. Inf1 :: 2008/09

Graphical User Interfaces

Overview. Applets. A Java GUI inside your browser! Important methods Drawing images Playing audio Getting input parameters Double buffering

Swing from A to Z Some Simple Components. Preface

Graphical User Interfaces (GUIs)

Java Help Files. by Peter Lavin. May 22, 2004

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

BCI.com Sitecore Publishing Guide. November 2017

Student Success Guide

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Visit for more.

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

Java Programming Lecture 6

Graphical User Interface (GUI)

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Packages: Putting Classes Together

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

CS415 Human Computer Interaction

BLACKBOARD PORTFOLIOS

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

University of Cape Town ~ Department of Computer Science. Computer Science 1016S / 1011H ~ January Exam

MIT AITI Swing Event Model Lecture 17

Class 16: The Swing Event Model

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Unit 6: Graphical User Interface

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

To complete this project, you will need the following folder:

Chapter 5: Enhancing Classes

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Containers. Atomic Components. Containment Hierarchy. Example Example 3.3 (revisited) Example DemoSwing.java

References. Chapter 5: Enhancing Classes. Enhancing Classes. The null Reference. Java Software Solutions for AP* Computer Science A 2nd Edition

Window Interfaces Using Swing Objects

Graphical User Interfaces 2

Introduction to concurrency and GUIs

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

To gain experience using recursion and recursive data structures.

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

GUI, Events and Applets from Applications, Part III

CSC 101: Lab #1 Introduction and Setup Due Date: 5:00pm, day after your lab session

Graphical User Interface (Part-1) Supplementary Material for CPSC 233

A Tool for Automated GUI Program Grading

PROGRAMMING LANGUAGE 2

Swing - JButton. Adding buttons to the main window

CS Exam 1 Review Suggestions

Chapter 4. Swing 18 marks

Graphical User Interfaces 2

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

Transcription:

CoSc 10403 Lab # 5 (The Controller) Due Date: Part I, Experiment classtime, Thursday, Oct 25 th, 2018. Part II, Program - by midnight, Thursday, Oct 25 th, 2018. Part I MUST be typed and submitted to your instructor at the BEGINNING of class on the due date. IT WILL NOT BE ACCEPTED LATE. Failure to print, left it in your dorm room, etc. are unacceptable excuses.ate. IT WILL NOT BE ACCEPTED LATE. Part II is the programming component. It should be submitted as a zipped file with two classes in the zip file: Lab3.java and Lab5.java using D2L. Submit the Lab5.zip file for grading. You should be aware that there is a Java reference readily available on the web (https://docs.oracle.com/javase/7/docs/api/) that can be used to find information on all Java packages, classes, methods, etc. Some questions in Part I are designed to help familiarize you with this web site. Part I. Experiment. (20%). Use the Java code provided in the files "Lab5ExperimentControl.java" and "Lab5ExperimentView.java" file. Put both files in your project's src folder to run the experiment. (Follow the same procedure that you used to create your past labs). Modify the width and height parameters as required in order to see all components (I recommend width=500 height=200) You will experiment with this code in answering some of the questions in this section. Testing this code will allow you to become familiar with the use of the extends clause in java by extending a view class into a control class. Also you will get practice using accessor methods to obtain information from JComboBox, JLists, JRadioButtons and JCheckBoxs along with the use of ActionListeners. Finally you will learn to add and play audioclips in java. For this you will need to add a subfolder sounds within your project folder as you did with images and put in it an audio clip that we are providing (i.e. oh.wav). REMEMBER - ALL EXPERIMENTS MUST BE TYPED NOT HANDWRITTEN!!!! Navigate to the Sun Java site whose URL is shown above. In the upper left-hand pane are listed the classes that are included in the standard Java Platform. Scroll down to find the

javax.swing class. In the javax.swing classes that are now presented to you in the lower left-hand pane, scroll to find the JComboBox, JList and JCheckBox classes and click on it. Answer the next questions using information derived from this page. 1. By referencing the javasoft web site, determine how you get the value of a given selection in the JComboBox? 2. By referencing the javasoft web site, determine how you get the value of a given selection in the JList? 3. How do you check if the JCheckBox has been selected? 4. In examining the methods defined in the JButton class the method addactionlistener() is not present, yet you have the ability to use it with method calls. How? For questions 5-9 perform each of the tasks described. (You should modify the Lab5Experiment code and run the program to verify your answers; after each question restore the code to its original form to continue) 5. What happens in the Lab5ExperimentControl if you remove the line: import java.awt.event.*; from the initial imports? 6. What happens in the Lab5ExperimentControl if you remove the clause: implements ActionListener from the initial line of the class? 7. What happens in the Lab5ExperimentControl constructor in the method clearmessage() if you remove the line: if(ohsound!= null ) ohsound.stop( ); What does this line do? 8. What happens in the Lab5ExperimentControl in the constructor method if you remove the lines: cancel.addactionlistener(this); and display.addactionlistener(this);

9. What happens in the Lab5ExperimentControl in the method displaymessage() if you change the line: ohsound.play( ); to ohsound.loop( ); 10. In the actionperformed(actionevent e) method exchange the lines: String whichbutton = e.getactioncommand(); if (whichbutton.equals("display")) displaymessage(); if (whichbutton.equals("cancel")) clearmessage(); For the lines: Object source = e.getsource(); if (source.equals(display)) displaymessage(); if (source.equals(cancel)) clearmessage(); What is the performance of the program? 14. Answer the following questions regarding the programming design of this code: a) What does the various calls to the method System.out.println() do? b) What do you think is the purpose of adding that statement? c) In the method displaymessage(), in the line course = (String)myList.getSelectedValue(); what does the clause (String) do? d) In the method clearmessage() what is the purpose of the line mylist.setselectedindex(0); Part II. Programming. (80%) Required for this assignment is a webpage software architecture pattern (called MVC, Model-View-Controller) that is designed to separate the representation of information from the user's interaction with it. The view manages the display of information (this is the software you developed for your Lab3 GUI). Using this design architecture, everything the user can see or interact with should be powered by the view.

The controller interprets the mouse and keyboard inputs supplied by the user (in this case events triggered by choosing JComboBox entries, clicking on JCheckBoxes, or clicking on JButtons (i.e., the controller handles user generated events)). The model (when implemented in a later assignment) manages the behavior and data of the application, responds to requests for information (usually derived from the view), and responds to instructions to change state (usually from the controller). In other words, these are the classes that contain data. The current Lab5 assignment will bring together the View (already implemented as your Lab3) and the Controller (your new code developed for Lab5) the Model will be implemented in a later assignment. The graphic to the right is intended to illustrate the interactions that occur among the separate pieces of an MVC architecture. Coding Strategy: Since presumably, you have already developed the view for this assignment as your Lab3, now is the time to develop the control part of the GUI by extending Lab3 into a new class Lab5. For this assignment you should reuse as much code as you can from your previous Lab3Project (this code will become your View exactly as it appeared for your Lab3); in this way you can concentrate on developing only the Control for your Lab5. Use only ActionListeners to get the information required Note: your Lab5Project will consist of two classes. Using the MVC model, Lab5 will be the CONTROL class while Lab3 is the VIEW class, therefore Lab5 will extends Lab3 and implements the ActionListener as indicated below: The header for your Lab5 will now read as: public class Lab5 extends Lab3 implements ActionListener. Please note that the constructor method in Lab5 will also call the constructor of Lab3. In this assignment you will only be using one ActionListener In this lab you will only use one ActionListener along with a getselectedindex() method from the JList and JComboBox to select the sandwich, drink side and size. The desired functional interaction of this Lab 5 is described below.

1) After you select a order of sandwich, drink and side from the JLists and select the sizefrom the JComboBox and when pressing the Place Order JButton the JApplet determines determines the cot of the order and pops up a JFrame with the details of the order it also should display the image. 2) The Grilled JCheckBox select whether the sandwich is to grilled or not. 3) The sound and animation JCheckBoxes do not have any interactivity in Lab5. 4) The Cancel button returns to JApplet to its initial state, resetting the JLists to the top, clearing the JComboBox, the Grilled JCheckBox and removes the Pop up JFrame Your applet should illustrate the use of ALL common widgets discussed in class as well as your skills to show images within the widgets. You will be graded on its appearance, the appropriate use of widgets and its correct functionality. Please feel free to be creative, here we provide our applet demo so you can get the look and feel we expect from your own implementation. Remember to submit as a zip file with two classes in the zip file: Lab3.java and Lab5.java using D2L Submit as Lab5.zip file for grading. Here we provide the desired interaction: Before the selection

After a complete selection (i.e. Sandwich, Side, Drink and Size)