QMCS 230: Today in Class - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

QMCS 230: Today in Class

Description:

9 Semicolon; double quotes; void. Mark 0' as undefined; insist on arguments ... Car type = new Car(); // type becomes the variable name #16-8 size on left ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 19
Provided by: ricks6
Category:
Tags: qmcs | class | today

less

Transcript and Presenter's Notes

Title: QMCS 230: Today in Class


1
QMCS 230 Today in Class
  • Administrative
  • Office Hours Today CANCELED
  • Project Schedule
  • This Week Schedule
  • About the Exam
  • Graphical User Interface (GUI)
  • See how far we get

2
This Week Schedule
  • Lecture/Lab Tomorrow
  • Lab Wednesday
  • LABS DUE
  • I will accept Lab 16 THIS WEEK
  • Deduct from grade for being late
  • Same with Lab 17 if not received tomorrow
  • Lab 18 due NEXT Tuesday

3
Project Schedule
  • Team and project THIS WEEK
  • Tell me next Monday
  • What youre doing who youre working with
  • Design Memo by December 3
  • What files/methods you will produce
  • What inputs and outputs will look like
  • Final Project Due last day of class

4
About the Exam
  • Total points 114 100
  • No real extra credit
  • I reduced the point values of some problems
  • Grades?
  • Class median 89
  • Percent (114 Missed) / 114
  • Above 90 is an A, etc.

5
Working through the answers
  • 1 People tended to forget throws
  • A few wrote headers for something not main
  • 2 It looks like a few people just guessed
  • Prompting for the filename FileWriter/PrintWriter
    for input
  • 3, 4 almost always right
  • 5 Grammar
  • 6-8 forget return type, arg types, arg names
  • Extra argument for the return value
  • 9 Semicolon double quotes void
  • Mark 0 as undefined insist on arguments
  • 10 array value passed to constructor
  • 12 weird grammar
  • 13 weird grammar not a constructor
  • 14 void String type

6
More answers
  • 15 writing a constructor method
  • Car type new Car() // type becomes the
    variable name
  • 16-8 size on left hand side
  • 17 double for size value
  • 18 forgetting
  • 19 Just needed 0-4
  • 20 Starting with 0
  • 21-23 using ArrayList operations
  • 21 Backwards assignment (several)
  • Bad syntax, like an add method
  • 23 using or instead of .equals()

7
GUIs what well do for graphics
  • Arranging windows with interface controls
  • Example the bookshelf lab or carpet lab
  • Implement with fields to fill in and a compute
    button
  • GUIs depend heavily on objects
  • A historical thing
  • Xerox PARC developed the modern GUI
  • They used an OO language to do it

8
Examples of GUI Objects
  • A Window (type JFrame)
  • Dimensions
  • A Title
  • Visibility
  • Close operation (what to do when closing)
  • Window Contents, including
  • Labels (type JLabel)
  • Contains settable text
  • Text Field (type JTextField)
  • Contains a readable text field
  • Buttons (type JButton)

9
Example GUI Objects
  • Can you spot JWindow, JTextField, JLabel,
    JButton...

10
Our Friend, JFrame
  • What it has dimensions, visibility, a title,
    actions, contents, etc.

11
Creating our own window
  • Windows are objects, lets create one
  • Import javax.swing.
  • JFrame Win new JFrame()
  • Win.setTitle(R. Smiths Object Test Window)
  • Win.setSize(350, 250)
  • Win.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE
    )
  • Win.setVisible(true)
  • Lets try it

12
To Create a Full GUI
  • We create customized Window objects
  • We take JFrame and customize it
  • Customizing through inheritance
  • When we inherit, we get the existing object
    features, fields, and methods
  • We replace any we want, or add new ones
  • We get a normal window plus what we need

13
Creating our own window object
  • Its an independent object put in its own file
  • Imports javax.swing.
  • Class declaration extends JFrame
  • Custom Constructor creates the window
  • Title setTitle(R. Smiths Object Test Window)
  • Size setSize(350, 250)
  • Close Button setDefaultCloseOperation
    (JFrame.EXIT_ON_CLOSE)
  • Visibility setVisible(true)
  • Lets try it

14
GUI from the book KM converter
  • Convert kilometers to miles

Text Field
Window Title
Label
Button
15
Features
  • Label describing what to do
  • Text field for the amount to convert
  • Button to run the conversion
  • Option add a label to hold the answer
  • For now, it wont do anything

16
Implementation
  • We create a special converter window type
  • We create objects for each GUI element
  • We attach the objects to the window object

17
Lab 18 GUI for bookshelf calculation
  • Features of the GUI
  • A label describing how to use it
  • Two text fields to collect the data
  • A button to do the calculation
  • Another label for outputs and error messages

18
Thats it.
  • Questions?
  • Creative Commons License
  • This work is licensed under the Creative Commons
    Attribution-Share Alike 3.0 United States
    License. To view a copy of this license, visit
    http//creativecommons.org/licenses/by-sa/3.0/us/
    or send a letter to Creative Commons, 171 Second
    Street, Suite 300, San Francisco, California,
    94105, USA.
Write a Comment
User Comments (0)
About PowerShow.com