Java Programming 4: Java Application Building

Java Programming 4: Java Application Building

Lesso n 1: Applicat io n Building Review Preview Impro ving Yo ur Co de Design Pattern: Mo del/View/Co ntro ller Separating Applicatio n fro m User Interface

Co ming Attractio ns: The View

Lesso n 2: Swing: A Ve ry Brie f Ove rvie w AWT vs. Swing Hello Wo rld in AWT and Swing Changing Appearance JApplets, JFrames, and Threads Mo re Info rmatio n o n Applets Mo re Info rmatio n o n JApplets

Even Mo re Swing

Lesson 3: Graphical User Int erf aces Views JFrames and JPanels JFrames: The To p-Level View

Lesson 4: Graphical User Int erf aces, co nt inued Making the Output Panel

Lesso n 5: Erro r Che cking and Exce pt io n Handling Being Prepared fo r Users Cras hes Expect the Unexpected

Handling Exceptio ns Finding the Pro blem Fixing the Pro blem

Try/Catch Clauses Anticipating Exceptio ns Making It Right: Dialo g Bo xes

Types o f Exceptio ns Checked Exceptio ns Unchecked Exceptio ns

The Other Pro blem

Lesso n 6 : Unche cke d Exce pt io ns: Ke e ping Our Applicat io ns Running Abo ut Exceptio ns Run-Time Exceptio ns NullPo interExceptio n Example 1

Example 2 Example 3 Example 4 Example 5 Divisio n By Zero Array Out o f Bo unds Array Out o f Bo unds Example 2

Erro rs Pro gramming Respo nsibly

Lesso n 7: Che cke d Exce pt io ns: Cat ching Pro ble m s Degrading Gracefully I/O Exceptio ns Exceptio n Types Using Try and Catch Fo rwarding the Exceptio n

Determining What To Do With Exceptio ns Thro wing Exceptio ns Exam ple Passing Exceptio ns to Other Metho ds Catching Exceptio ns fro m Other Metho ds One Mo re Time

Exceptio n Hierarchy Using Finally in a Try/Catch Blo ck

Additio nal Info rmatio n

Lesson 8: T hreads: Int ro duct io n Multi- Tas king Threads Subclassing the Thread Class Manipulating Threads Threads in Applets

Implementing the Runnable Interface One Mo re Time

Lesson 9: T hreads: Co ncurrent Pro gramming Behind the Scenes Multi-threaded Applicatio ns The Life o f a Thread What's Happening in the Backgro und? Garbage Co llectio n

Thread States Thread.State Mo re o n Multi-Threaded Applicatio ns

Design Pattern: Pro ducer/Co nsumer Using Threads in an Applicatio n

The Pro ducer The Co nsumer The Mo nito r The GUI View

Lesso n 10 : T hre ads: Synchro nizat io n Race Co nditio ns Fixing a Race Co nditio n Ano ther Race Co nditio n Additio nal Reso urces Using Threads in a Game Creating the Typing Game Preview: The Classes The Bo mb Pro ducing Wo rds Co nsuming Keys Mo nito ring Wo rds The User Interface

We Lo ve Threads Real Games Blackjack

Lesso n 11: Dat abase s: Co nne ct ivit y t hro ugh J ava The JDBC API What is JDBC? What Do es JDBC Help Us Do ?

Co nnecting to the Database Access to a Database The Driver Verifying the Co nnectio n

The Facto ry Design Pattern Testing Our Co nnectio n

The Main 1: Pro viding Parameters In Co de 2: Giving Parameters in Eclipse

Sending SQL Statements User Access and Input Clo sing Our Co nnectio ns

Additio nal Reso urces

Lesso n 12: Dat abase s and J ava: Pro ce ssing Inf o rm at io n Getting Results Databases and SQL Res ultSet

Getting Info rmatio n Abo ut Info rmatio n Metadata

Creating a Table

Clo sing Pro perly Seeing Table Co ntents SQL Co mmands Lo gging In

Lesso n 13: Dat abase Applicat io n Wit h GUI Refining the Applicatio n Impro ving the Appearance Co pying an Existing Class Creating New Classes

Creating the View Creating Co ntro llers fo r the View Additio nal Reso urces

Lesso n 14: Do cum e nt at io n: J avado c, Do c Co m m e nt s, and Anno t at io n Do cumenting Yo ur Wo rk Javado c and API Pages Databas eManager Creating Javado cs

Do cumenting and Tagging the Applicatio n SimplePho neBo o k Pho neBo o kFrame ListingsTableMo del AddLis tingLis tener AddListingDialo g Pho neDo cumentListener Pho neFo cusListener

The Package Do cumentatio n Additio nal Reso urces What's Next?

Copyright ? 1998-2014 O'Reilly Media, Inc.

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. See for more information.

Application Building

Welco me to the J ava Applicat io n Building series o f Java co urses. This series will fo cus o n develo ping applicatio ns using the many to o ls available in Java. As in all OST co urses, the emphasis will be o n interactive instructio n.

Course Objectives

When yo u co mplete this co urse, yo u will be able to :

enhance Graphical User Interfaces in Java using views, frames, panels, and Swing. implement erro r checking, exceptio n handling, and try/catch clauses to minimize bugs. catch unchecked exceptio ns and prepare fo r pro blems thro ugh graceful degradatio n. create and manipulate threads fo r co ncurrent pro gramming. co nnect with databases using the JDBC API, facto ry design patterns, and view co ntro llers. do cument and tag co de using Javado c and API pages.

In this co urse, yo u will achieve an understanding o f the structure and purpo ses fo r many o f the classes in the Java API. In-depth experience with user-interfaces, event and exceptio n handling, database co nnectivity, multiple threads and synchro nizatio n will pro vide yo u with a to o lkit fo r bo th implementing applicatio ns as well as understanding so urce co de o f o thers. Pro grams designed in the co urse using Java Threads, Client/Server So ckets and Database Co nnectivity pro vide a so lid basis fo r applicatio n building.

Fro m beginning to end, yo u will learn by do ing yo ur o wn Java pro jects, within o ur Eclipse Learning Sandbo x we affectio nately call "Ellipse". These pro jects will add to yo ur po rtfo lio and pro vide needed experience. Besides a bro wser and internet co nnectio n, all so ftware is pro vided o nline by the O'Reilly Scho o l o f Techno lo gy.

Review

In this series, we assume that yo u have a general fo undatio n o f Java and o bject-o riented pro gramming kno wledge, so basic pro gramming skills wo n't be co vered in this co urse. We'll wo rk no w to gro w and refine yo ur existing Java pro gramming skills. If yo u are unable to fo llo w the co de that we use fo r illustratio ns and examples in this co urse, we reco mmend that yo u take OST's first Java series o f co urses to gain tho se basic pro gramming skills; then yo u'll be able to reap the full benefits o f the materials presented here.

If yo u are new to OST co urses, read this o verview befo re yo u go further.

In the previo us co urse, we went o ver these co ncepts:

Co de flexibility Package declaratio n and usage Separatio n o f classes to mo del the Mo del/View/Co ntro ller (MVC) design pattern Interfaces Cas ting Declaratio n and use o f inner classes

We'll apply these ideas and mo re as we impro ve o ur Sales Repo rt applicatio n.

Preview

In the first new versio n o f o ur applicatio n, we'll bring in Layo ut Manage rs to pro vide a better user interface. Except fo r the vario us Layo ut Manage rs and Pane ls, we'll also be using familiar co de and techniques. In upco ming lesso ns, we will learn additio nal techniques that will enable us to :

pro vide exceptio n handling. make better GUIs. allo w applicatio n deplo yment using jars and executables. add input fro m o ther so urces (such as databases and "o ffsite" machines). allo w multiple peo ple to use the same applicatio ns at the same time (threads).

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download