Read an Excerpt
PREFACE:
INTRODUCTION
When I began writing my first introductory Java text in the summer of 1996, only a few schools were teaching Java. Today, Java has become the programming language of choice for many schools. The incorporation of Java into the computer science curriculum has increased the need for an advanced Java text. This book covers the advanced Java features that are needed to support upper-level CS courses, such as software engineering, graphics, database programming, and distributed programming. It can be used as a text for advanced Java programming or as a supplement for upper-level CS courses. In addition, it is perfectly suitable for Java programmers who want to learn rapid application development techniques using JBuilder.
In this book I introduce the concepts of JavaBeans, bean event model, model-view control, developing customized components, Swing components, creating custom layout managers, bean persistence, bound properties and constraint properties, bean introspection and customization, Java database programming, and distributed programming using remote method invocation or CORBA. The main thread of the book, however, is to promote rapid Java application development. Rapid application development, or RAD, is a software development technology for developing programs efficiently and effectively. This technology has been successfully implemented in Visual Basic, Delphi, Power Builder, Oracle Developer 2000, and many other program development tools. Using a RAD tool, projects can be developed quickly and efficiently with minimum coding. Projects developed using RAD are easy to modify and easy to maintain. The key elements in a RAD toolare the software components, such as buttons, labels, combo boxes, lists, check boxes, radio buttons, and menus. These components can be visually manipulated and tailored during design time in order to develop customized programs.
One of the central issues in software development is how to reuse programs effectively. Java is an object-oriented programming language that provides great flexibility, modularity, clarity, and reusability through method abstraction, class abstraction, and class inheritance. A Java program can be viewed as a collection of cooperating objects that are created during runtime. The JavaBeans technology is a significant extension and enhancement of the Java language that makes it possible for programmers to rapidly build applications by assembling objects and testing them during design time, thus making reuse of the software more productive.
To facilitate developing and managing Java programs, the book is aided by JBuilder. JBuilder is one of the best Java tools that rapidly simplify Java program development for maximum productivity. JBuilder provides a fully scalable, distributed, and cross-platform architecture for building reusable components. JBuilder provides a tightly integrated development environment that lets you visually design user interface and rapidly build applications with the UI Designer and Menu Designer. JBuilder BeansExpress makes it point-and-click easy to create standard JavaBeans. JBuilder also contains many intelligent wizards that are convenient to use to generate source code automatically.
Throughout the book there are numerous examples with step-by-step instructions that guide you in creating reusable components and using them to assemble large practical applications. It is assumed that you are familiar with the basics of Java programming, including creating graphical user interface using Swing, exception handling, internationalization, multithreads, IO streams, and networking. These topics are covered in my introductory Java text, Introduction to Java Programming (3rd edition), or in my Introduction to Java Programming with JBuilder 3 (PrenticeHall).
One of the major considerations in choosing JBuilder to teach Rapid Java Application Development is the clarity of the JBuilder-generated source code. The source code generated by JBuilder UI Designer, Menu Designer, and various wizards does not contain any proprietary code. Thus, the JBuilder-generated source code is easy to read and to maintain. With JBuilder, students can not only develop Java programs more productively, but can also learn advanced Java programming more effectively by following the source code.
All the examples in the text are developed with JBuilder Standard Edition except those in Chapters 14 and 16. Chapter 14, "Applications Using JBuilder DataExpress and Data-Aware Components," creates database projects using the Java bean components provided by Borland, which are available in JBuilder Professional Edition. Chapter 16, "Multi-Tier Application Development Using CORBA," introduces VisiBroker, which is bundled in JBuilder Enterprise Edition. These two chapters are optional, and can be skipped.
Most of the examples in this book are Java applets. A main method is provided for each applet to enable it to run standalone. However, for the sake of brevity, the main method is not listed in source code in the text.
Pedagogical Features of this Book
Rapid Java Application Development Using JBuilder 3 uses the following elements to get the most out of the material:
- Objectives lists what students learn from the chapter. This helps students to determine whether they have met these objectives after completing the chapter.
- Introduction opens the discussion with a brief overview of what to expect from the chapter.
- Programming concepts are taught by representative Examples, carefully chosen and presented in an easy-to-follow style. Each example is described, and includes the source code, a sample run, and an example review. The source code of the examples is contained in the companion CD-ROM. Almost all of the examples can run in two modes: standalone application or applets. Each program is complete and ready to be compiled and executed. The sample run of the program is captured from the screen to give students a live presentation of the example. Reading these examples is much like entering and running them on a computer.
- Chapter Summary reviews the important subjects that students should understand and remember. It also helps students to reinforce the key concepts they have learned in the chapter.
- Chapter Review helps students to track their progress and evaluate their learning.
- Programming Exercises at the end of each chapter provide students opportunities to apply the skills on their own. The trick of learning programming is practice, practice, and practice. To that end, this book provides a large number of exercises.
- Notes, Tips, and Cautions are inserted throughout the text to offer students valuable advice and insight on important aspects of program development:
- NOTE: Provides additional information on the subject and reinforces important concepts.
- TIP: Teaches good programming style and practice.
- CAUTION: Helps students steer away from the pitfalls of programming errors.
The Organization of This Book
Java is a comprehensive and powerful language with many evolving features. There is plenty of room for advanced Java text. This book, however, is centered on rapid Java application development. It is divided into five parts that, taken together, form a comprehensive course on rapid Java application development.
The early chapters introduce JavaBeans, which are the basis of rapid Java application development. Subsequent chapters apply Rapid Application Development techniques to build comprehensive, robust, and useful graphics applications, database and client/server applications, and distributed applications, with step-by-step instructions.
Part I: Introduction to Builder and JavaBeans
The first part of the book begins with an introduction to JBuilder 3, presents the concept of JavaBeans, discusses the bean event model, introduces the model-view architectures, and teaches developing and using beans in rapid Java application development.
Chapter 1, "Getting Started with JBuilder 3," gives an overview of JBuilder's integrated development environment. You will learn how to develop Java programs with a variety of JBuilder wizards for creating projects, applications, applets, and classes, and how to compile and run programs.
Chapter 2, "Introduction to JavaBeans," introduces the concept of JavaBeans. This chapter explains the relationship between JavaBeans and Java RAD builder tools, and shows you how to write simple JavaBeans and visually manipulate the beans in JBuilder.
Chapter 3, "Bean Events," covers the Java event delegation model, inner classes, and anonymous inner classes. You will learn how to develop source beans and listener beans and how to hook the source beans with the listener beans in JBuilder.
Chapter 4, "Developing and Using Components," discusses the differences between developing beans and using beans in rapid Java application development. This chapter introduces the model-view architecture. You will learn how to use the BeansExpress Wizard to create properties and events and the Deployment Wizard to deploy applications and applets.
Part II: Rapid Application Development with Swing Components
The book's second part covers Swing components and their use in rapid Java application development. You will learn how to use a variety of Swing components to develop Java projects using JBuilder 3.
Chapter 5, "Swing Components," introduces the concept of Swing components and discusses the differences between lightweight components and heavyweight components. You will learn how to use various Swing components in rapid application development.
Chapter 6, "Containers and Layout Managers," introduces Swing containers and layout managers, examines the structure of Swing containers, and studies the layout managers provided in JBuilder. You will learn how to create custom layout managers and install them in JBuilder. The components JTabbedPane, and JsplitPane are also covered in this chapter.
Chapter 7, "Menus, Toolbars, and Dialogs," introduces menus, popup menus, toolbars, Joptionpane dialogs, custom dialogs, JColorChooser, and JFileChooser. This chapter also teaches you how to use the Menu Designer to visually design menus and popup menus.
Chapter 8, "Advanced Swing Components," shows how to use several advanced Swing components, such as JList, JComboBox, JTable, and JTree, in rapid application development. You learn various data models, selection models, renderers, and editors for supporting these advanced components.
Part III: Bean Persistence, Interoperability, Introspection, and Customization
This part introduces the JavaBeans API. You will learn how to develop persistent beans, use bound and constraint properties, and create bean property editors.
Chapter 9, "Bean Persistence, Versioning, and Using Beans in Other Tools," introduces object serialization, which is a Java built-in mechanism for persistently storing and restoring beans. You will learn how to use Sun's Beanbox, a tool for testing beans, which can be used to verify bean persistence. You will also learn to customize serialization and bean versioning. Several examples that use JavaBeans in non-Java tools, such as Visual Basic and Word, will be demonstrated to give you a broad view of JavaBeans versatility.
Chapter 10, "Bound and Constraint Properties," introduces bound and constraint properties. A bound property of a component is one for which a property notification service is provided when the property changes. A constraint property allows the listener component to verify the property change to determine whether to accept or reject a change. These properties are useful for creating custom property editors.
Chapter 11, "Bean Introspection and Customization," takes an in-depth look at how builder tools learn bean information through introspection. You will learn how to create and deploy custom editors.
Part IV: Java Database Programming
This part of the book is devoted to developing database projects using Java. You will learn the Java database programming interface, handle database metadata, create and process SQL statements, and use JBuilder database beans for rapidly developing Java database applications.
Chapter 12, "Introduction to Java Database Programming," begins with an overview of the JDBC interface for accessing relational database from Java. A thorough introduction to the four types of the JDBC drivers is presented through examples of the use of MS Access, Oracle, and InterBase.
Chapter 13, "Metadata and Statements," gives a comprehensive treatment of obtaining database metadata, and processing statements, prepared statements, and callable statements.
Chapter 14, "Applications Using JBuilder DataExpress and Data-Aware Components," teaches you how to use JBuilder's powerful data access beans and dataaware Swing components for rapidly developing database applications.
Part V: Distributed Java Programming
The book's final part introduces the development of distributed projects using Java. You will learn how to use Remote Method Invocation (RMI) and CORBA to develop distributed applications using JBuilder.
Chapter 15, "Distributed Programming Using Java Remote Method Invocation," introduces Remote Method Invocation, a technology providing a framework for building distributed Java systems. You will learn how to use it to create useful distributed applications.
Chapter 16, "Multi-Tier Application Development Using CORBA," introduces Common Object Request Broker Architecture, a technology for creating interoperable distributed object systems. You will learn how to create distributed applications using VisiBroker, a product by Inprise that implements the CORBA technology using Java.