CSCI E70 Graphical User Interface Programming in Java

  • Slides: 15
Download presentation
CSCI E-70 Graphical User Interface Programming in Java 29 January 2003 Instructor: Daniel Bromberg,

CSCI E-70 Graphical User Interface Programming in Java 29 January 2003 Instructor: Daniel Bromberg, Mitsubishi Electric Research Labs 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 1

Welcome to E-70! • Extend Java skills to advanced client-side libraries – the java.

Welcome to E-70! • Extend Java skills to advanced client-side libraries – the java. awt and javax. swing package families • Apply skills with generic libraries – java. util. Collection, java. net, java. lang, . . . • Improve programming fluency – Apply data structures to solve cool problems – Learn more Object-oriented design, techniques – Perfect Java language knowledge: syntax, idioms, limitations • Learn the multi-threaded, event-driven, framework-based, visual modeling way of life • Make programs ordinary people can actually use • Think hard, code a lot, have fun 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 2

Course Layout • Lectures – Every Wednesday from Jan. 29 to May 14 excl.

Course Layout • Lectures – Every Wednesday from Jan. 29 to May 14 excl. holidays • Maxwell Dworkin G 135, 5: 30 -7: 30 PM • 5 minute break at the hour – Primarily presentation and demonstrations by Instructor • Theory, example, motivate, guide to important study points • Present homeworks, projects, tests; outline requirements • Announce changes in policy, schedule – Questions and discussions as needed • Section – Tentative After lecture, 8 -9 PM, Location TBA – Led by your Teaching Fellow – Driven almost entirely by student questions and needs 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 3

Additional Help • Web Site – http: //www. fas. harvard. edu/~libe 70/current • Check

Additional Help • Web Site – http: //www. fas. harvard. edu/~libe 70/current • Check constantly for updates, hints, notes – Please read entire syllabus – many important details • Ultimate Bulletin Board – Group technical discussions – Moderated by staff – both TFs and I contribute • E-mail TFs with private questions, grading issues • Attend regular TF office hours – Possibly schedule additional if need more help • Contact instructor – course policy questions – general concerns & complaints – office hours by appointment • Come to us one way or another; don’t sink or disappear 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 4

Workload • 1 st half: 5 -6 problem sets: 40% – Exercises. short programs,

Workload • 1 st half: 5 -6 problem sets: 40% – Exercises. short programs, practice “project” • Mid-game summary: Midterm Exam: 15% – Keep you on-target; gauge individual mastery – root out technical weaknesses before final project • SPRING BREAK! • 2 nd half: The Final Project (approx. 5 weeks) 45% – 3 stages (progessive building blocks) • Proposal (2 -3 pages) • Design charts & Class skeletons (5 -8 pages) • Final package (code + documentation, 15 -30 pages) 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 5

Books & References Required: Graphic Java 2, Volume 2: Swing (3 rd Edition) by

Books & References Required: Graphic Java 2, Volume 2: Swing (3 rd Edition) by David M. Geary: Prentice Hall PTR; ISBN: 0130796670; 3 rd edition (March 12, 1999) Java Event Handling by Grant Palmer: Prentice Hall PTR; ISBN: 0130418021; Bk&Cd-Rom edition (August 8, 2001) Recommended: Java 2 D API Graphics by Vincent J. Hardy: Prentice Hall PTR; ISBN: 0130142662; 1 st edition (November 3, 1999) (Especially if you think final project will involve drawing) Others: see “recommended reading” handout Topley: Advanced text & document formatting Zukowswi: Extra JBuilder practice Robinson et al. : Practical GUI middleware Walrath et al. : Printed Sun tutorial Lewis et al. : Multithreaded applications 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 6

Prerequisites • Enjoy using a GUI; no GUI programming needed • Data Structures experience:

Prerequisites • Enjoy using a GUI; no GUI programming needed • Data Structures experience: beyond int x; float y; . . . – one-dimensional arrays and loops should be “old hat” – understand tables, trees, and graphs in order to apply them • Fine to use library classes: java. util. Collection et al. • Java/OO experience: beyond one big main(). . . – Declaring base classes, derived classes • Polymorphism (just another Big Word? ) – Formal vs. actual data types are different but “compatible” – Reference semantics of objects • Passing an Object as a parameter sends a reference to receiver – Notion of “incomplete” classes • pure functional: interfaces • mixed implementation/functional: abstract classes – Don’t panic – we’re here to practice all of this! 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 7

Submitting Work • Use the ‘submit’ facility on Harvard Unix system – personal workstation,

Submitting Work • Use the ‘submit’ facility on Harvard Unix system – personal workstation, fas. harvard. edu, ice. harvard. edu – NO other method will be accepted! (no paper) – man submit(1): see examples; course is cscie 70 • Late penalty of 5% per day including weekends – However: 8 free late days. Entirely self-budgeted. – Intended for occasional “soft” extension – water pipe burst – kid ate your homework – got sick – snow storm – disk crashed • It will happen • MAKE BACKUPS EVERY DAY PLEASE! – Therefore any other extension only for medical emergencies • Deadlines fall on Friday just before midnight – Gives you time to mull over Wednesday’s section 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 8

Getting Started with Development • By next class, be able to run Java 2

Getting Started with Development • By next class, be able to run Java 2 SDK 1. 4 – Edit, compile, test Java/Swing programs • By 3 rd class, need JBuilder environment – Will be installed in 53 Church St. – Personal Edition 8 is free download • Establish work environment now – at Harvard, work, home, laptop, or combination – See HASCS guide off of www. fas. harvard. edu • Will distribute CD next week – Online book, JDK 1. 4 Java. Doc, JBuilder, readings, code Stop for Questions 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 9

Submission Standards • Clean code – – Header comments: name, date, purpose, implementation notes

Submission Standards • Clean code – – Header comments: name, date, purpose, implementation notes Thoughtfully chosen variable, constant, and class names Consistent indentation and spacing style Comments describing inputs, outputs, errors, and “side effects” of every major function • Evidence of testing – Show graceful error handling & non-trivial, valid inputs • Often means 2 -3 well-chosen screendumps of a GUI in action • Accompanying documentation as requested – Projects: UML diagram, user manual, architectural overview. . . • Standards will become stricter as we provide feedback – Try your best for now; focus on clean code 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 10

Java: my take • Best widely available OO language I know of – Far

Java: my take • Best widely available OO language I know of – Far from perfect • too “safe”? bounds checking slows performance • too compromised by C legacy? primitive vs. object dichotomy • Fought over by Micro$oft – Court ordered re-integration to Windows – But C# is an up-and-comer? Will. NET dominate? • Industry battles: I shrug it off – Java not independently standardized (like C) • May not last forever • As a developer, be flexible and switch when the time comes – Learn good Object Oriented programming • applicable from C through Python to Java and beyond! 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 11

Let’s Swing! • AWT/Swing libaries are a monstrous hairy beast – Fear not for

Let’s Swing! • AWT/Swing libaries are a monstrous hairy beast – Fear not for ye shall wrestle them to the ground • Explain architecture on-demand for now – Get your feet wet – Tie code to visuals • Let’s put up a window – – – import: the GUI packages JFrame et al. : “Heavyweight” components content. Pane: access to body area Border. Layout: basic component layout manager JButton: interactive control Action. Listener / Action. Event: event handling 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 12

start Visual States standard windows decoration & titlebar; inside controlled by pure Java renderers

start Visual States standard windows decoration & titlebar; inside controlled by pure Java renderers pressed inside hilights released outside un-hilights e nted d i ns pri i ed sgs s a m e rel ges; n a h tc • Note dotted outline; means component has focus • can use space bar to fire • more on focus later resizable unless specified otherwise. centered component grows to fill bounds tex pressed inside hilights released outside un-hilights released inside un-hilights; msgs printed 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 13

State Machines a • In essence – Stripped-down history of program’s execution • Only

State Machines a • In essence – Stripped-down history of program’s execution • Only what you need to react correctly to future events b – Theoretical basis of the “data models” I will be rambling about • Big Stuff – Underlies Computer Science and Computer Engineering at all levels • Practical and efficient once discipline learned – Ideally suited for processing unpredictable input over long periods – Forces understanding of the problem you’re solving 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 14

Follow-up Review and additional detail: http: //java. sun. com/docs/books/tutorial/uiswing/start/index. html especially. . . /start/swing.

Follow-up Review and additional detail: http: //java. sun. com/docs/books/tutorial/uiswing/start/index. html especially. . . /start/swing. Tour. html Problem Set 1: • Student Survey • Programming – – – due at end of class due Friday Feb 7 11: 59. 999. . . Install J 2 SE SDK v 1. 4 Make program modifications Turn in screen dump, code listing Turn in modified state diagram Answer questions to exercises Submit package to cscie 70 library account on FAS Unix system Stop for Questions 29 Jan 2003 CSCI E-70 Lecture 1 / Bromberg 15