Table of Contents

dedication xviii
preface xix
author online xxiii

Part I Build your own beans 1
1 Introduction 3
          1.1Visual assembly 4
Design time versus run time 5
1.2Scenarios 5
A simple scenario 5, A complex scenario 5
1.3Bean basics 7
1.4Applets and beans 9
1.5Bridging the gap 9
1.6WWW browser support for JavaBeans 10
1.7Relevant technologies 10
1.8What's in store for JavaBeans? 10
Glasgow specifications 11, InfoBus 11, Enterprise JavaBeans 12
1.9Where to start? 12
1.10Intended audience 13
1.11Where to get some beans 14
2 JavaBeans model 15
2.1Describing a Java bean 16
Introspection 17
2.2Design-time classes 18
2.3Run-time classes 19
Properties 19, Events 22, Adapters 28, Exposing events 30, Timer: an example of a custom event 31, Methods 33, Bound and constrained properties 34
2.4Persistence 36
Serialization 36, Implementing serialization 37, Persistent versus transient fields 38
2.5Packaging beans 42
2.6Summary 43
3 Creating and assembling simple beans 45
3.1Overview of the BeanBox 46
Running the BeanBox 46, Loading beans 47
3.2Creating simple beans 47
Requirements and design 47, Implementation 48
3.3Visual assembly 56
Running the BeanBox 56, Running your application 60
3.4Manual assembly 62
Creating a bean instance 62
3.5Summary 64
4 Building run-time bean classes 65
4.1Class libraries versus beans 66
4.2Designing beans 66
Designing properties 67, Designing methods 67, Designing connection strategies 69, Class design 71, Package design 72
4.3Implementing run-time classes 73
Constructor with no arguments 73, Conformance to design patterns 74, Implementing multiple bean classes 74, Implementing serialization 75, Implementing property change events 77, Implementing a bound property 78, Listening to bound properties 79, Using bound properties for connecting beans 79, Implementing a constrained property 83, Listening to constrained properties 86
4.4Summary 87
5 Building design-time classes 89
5.1Providing bean information 90
5.2Building BeanInfo classes 91
Overview of the BeanInfo interface 92, Steps to build a BeanInfo class 93, Constructing feature descriptors 93, Multiple bean classes 104
5.3Building BeanInfo classes: a quick reference 111
5.4Design-time utilities 112
Bean instantiation 112, Checking for an instance 114, Checking for design time 114, Checking for GUI availability 115
5.5Using the Introspector class 115
A BeanInfo tester 117
5.6Summary 122
6 Building property editors and customizers 123
6.1Property editor 124
Overview of the PropertyEditor interface 124, How do property editors work? 126
6.2Building custom property editors 128
PropertyEditorSupport class 128, Editors for property presented as text 128, Indexed property editor 132, Editors for enumerated types 135, Editors with custom components 143
6.3Registering and locating and editors 148
Registering editors 148, Locating editors 150
6.4Customizers 150
Property sheet limitations 150, Building customizers 152, Registering and locating customizers 162, Customizer limitations 162
6.5Summary 163
7 Packaging and delivery 165
7.1Java archive 165
Using the jar tool 166, Manifest file 167
7.2What goes in a beans jar file? 169
7.3Data compression 170
The java.util.zip class library 170
7.4Accessing resources using the zip class library 174
7.5Example: jar image browser bean 176
Location independent accessing of resources 179, Example: Jar Viewer bean 181
7.6Summary 185
8 Applets and beans 187
8.1Applet basics 188
HTML tags 188, Applet class 189
8.2Making an applet a bean 189
Applet bean initialization 190, Configuring an applet 191, Rotator: example of an applet bean 191, Converting your applet into a bean 197
8.3Converting your bean into an applet 197
Using the BeanWrapper class 197, Using the MakeApplet utility 198
8.4Summary 200
9 JavaBeans to ActiveX 201
9.1ActiveX overview 202
COM basics 203, Flavors of ActiveX 204, ActiveX and the web 206
9.2ActiveX bridge 207
How does it work? 207, OLE packager 207, Properties 212, Methods 212, Events 212, Implementing persistence 213
9.3Running beans in Visual Basic 213
9.4Running beans in Internet Explorer 217
Steps 218, Embedding beans in Microsoft Office applications 222
9.5Tips with working with bean controls 223
9.6Unregistering beans 223
9.7Conclusion/summary 224
10 ActiveX to JavaBeans 225
10.1Introduction to ActiveX controls 226
10.2ActiveX controls on Visual C++ 227
ActiveX Template Library (ATL) 227, BaseCtrl framework 227, Microsoft Foundation Classes (MFC) 227
10.3The MFC way 227
10.4The progress indicator ActiveX control 228
10.5Creating our control 228
The OLE Test container 229
10.6The simplest MFC ActiveX control 230
10.7Adding features to our control 230
Properties 231, Methods 237, Events 238, Drawing our control 238, Implementing property pages 240, Message handling 241, Error handling 241
10.8Caveat emptor! 241
10.9Security issues 242
Registry manipulation 242, Implementing the IObjectSafety interface 242
10.10Running the control 243
10.11The Migration Assistant 244
10.12Benefits to using the migration assistant 245
10.13Availability and installation 246
10.14Converting our ActiveX control to a JavaBean 246
10.15Problems with the generated code 249
10.16Making it a complete bean 251
10.17Running our bean in a BeanBox 254
10.18Microsoft's JActiveX 254
10.19Summary 260
11 Building beans using tools 261
11.1Borland's JBuilder 262
Overview of JBuilder 262, AppBrowser 263, Build your beans using JBuilder 264, Adding beans to the component palette 267, Connecting beans 268
11.2PowerSoft's PowerJ 273
Overview of PowerJ 273, Building beans 275, Packaging beans 278, Adding beans to the component palette 278, Customizing beans 279, Connecting beans 281
11.3VisualAge WebRunner bean tools 283
BeanTester 283
11.4Summary 291
12 Advanced JavaBeans 293
12.1Limitations of the basic model 294
12.2Glasgow specifications 294
Run-time containment and services protocol 295, Overview of the bean context API 295
12.3JavaBeans activation framework (JAF) 302
JAF basics 303, Overview of the JAF API 304
12.4InfoBus 309
InfoBus basics 310, Creating a new instance of InfoBus 311, Becoming an InfoBus member 311, Joining and leaving an InfoBus 312, Becoming a data producer or data consumer 313, Exchanging data 314, Becoming a data controller 316, Describing data 319
12.5Summary 325

Part II Bean collection 327
List of beans 329
13 Visualization bean suite 331
13.1Visualization package organization 332
vis.util package 332, vis.beans package 332
14 File selector bean 337
14.1Exposed properties 338
14.2Methods 339
14.3Exposed events 339
Connection 340
14.4Run-time classes 341
List select event 342
14.5Design-time classes 342
14.6Conclusions 345
15 A simple numeric spreadsheet bean 347
15.1Exposed properties 349
Hidden properties 350
15.2Exposed methods 350
Exposed events 351, Observed events 351
15.3Connection 352
As a target 352, As a source 352
15.4Run-time classes 353
SpreadSheet class 354
15.5Design-time classes 356
15.6Proposed improvements 356
16 Plotter beans 357
16.1Scientific plotting 357
Business charts 359
16.2Exposed properties 359
Common properties 359
16.3Exposed methods 363
Common methods 363
16.4Events and connection 364
16.5Run-time classes 364
Base classes 364, PieChart class 371
16.6Design-time classes 372
ChartBeanInfo class 376, BarChartBeanInfo class 377
16.7PieChartBeanInfo class 378
Customizers 381
16.8Business chart bean 381
Exposed properties 381, Exposed methods 381, Run-time classes 381, Design-time classes 384
17 ImageViewport bean 387
17.1Features 388
Image display modes 388, Image orientation 389, Scroll 389, Magnification 389, Cine' 389
17.2Exposed properties 390
Exposed methods 391, Exposed events 393
17.3Run-time classes 393
ImageCanvas class 393, ImageLoader class 396
17.4Design-time interfaces 397
ImageCanvasBeanInfo class 397, Customizer 401
18 Image loader bean 411
18.1Image loading basics 412
Asynchronous loading 412, Image loading stages 413, Image loading problems 414
18.2Exposed properties 420
18.3Exposed methods 420
18.4Exposed events 421
18.5Observed events 421
18.6Connection 421
18.7Run-time classes 421
Loader class 422, Image loaded event 425
18.8Design-time classes 425
18.9Proposed improvements 425
19 Image manipulation beans 427
19.1Image display bean 427
Properties 428, Exposed events 429, Connection 429, As a source 429, As a target 430, Run-time classes 430, Design-time classes 432
19.2Cine' bean 434
Exposed properties 434, Exposed methods 435, Exposed events 436, Observed events 436, Connection 436, Run-time classes 436, Design-time classes 438
19.3Pan/Zoom bean 438
Exposed properties 438, Exposed methods 440, Events 440
19.4Run-time and design-time classes 440
19.5An image viewer 440
20 JDBC select bean 441
20.1Requirements 442
20.2Exposed properties 442
20.3Exposed methods 444
20.4Exposed events 444
Connection 444
20.5Run-time classes 445
Loading drivers classes 445, Querying the database 446, JDBC Select GUI bean 447
20.6Design-time classes 448
20.7Creating a sample application using JDBC select 449
Data Source creation 449, Creating sample application 449
21 File printer bean 451
21.1Requirements and design 451
21.2Exposed properties 453
21.3Exposed methods 454
21.4Exposed events 454
21.5Design-time classes 455
Customizer 455, Property editor for line spacing property 455
21.6Conclusion 455
22 The Bean Collaborator 457
22.1Motivation 457
22.2Using the Bean Collaborator 458
22.3Potential uses and limitations 461
22.4Exposed properties, methods, and events 461
22.5Bean class design and implementation 461
22.6Important issues addressed 463
22.7IDL code snippets 463
Joining/leaving session 463, Event replication 464
22.8Design-time interfaces 465
BeanCollaboratorBeanInfo class 465, BeanCollaboratorCustomizer class 465
22.9References 468
23 Jzoom 469
23.1Properties 469
23.2Future improvements 470

Part III Appendix 471
Appendix A: A recipe to write your own beans 473
Appendix B: Using the reflection API 477
Class class 478
Fetching class objects 478, Fetching method objects 481, Fetching constructor objects 482, Other methods in Class 482
java.lang.reflect package 483
Member interface 483, Method class 483, Constructor class 487, Field class 488, Modifier class 488
JDK 1.2 enhancements 488
AccessibleObject class 488
Appendix C: The beans API 489
Introspection classes/interfaces 490
BeanInfo interface 490, SimpleBeanInfo class 491, Introspector class 491, Feature descriptor classes 492, IntrospectionException class 498
Customization 499
PropertyEditor interface 499, PropertyEditorSupport class 499, PropertyEditorManager class 500, Customizer interface 500
Property change event notification classes 500
PropertyEvent class 501, PropertyChangeListener interface 501, VetoableChangeListener interface 501, PropertyChangeSupport class 502, VetoableChangeSupport class 502, PropertyVetoException class 503, Designtime utility classes 503, Beans class 503, Bean instance methods 503, Visibility interface 504
JDK 1.2 enhancements 504
Support for bean contexts 504, Support for applets 505, Aggregation and delegation 506
Appendix D: Miscellaneous 509
Inner classes 509
Top-level classes 510
Inner classes 510
Member inner classes 511, Local classes 513, Anonymous classes 513
Collections and maps 521
Collection interface 521, List interface 522, Set interface 523, Map interface 524, java.lang.Comparator interface 525, Comparator interface 525, Iterator interface 525, ListIterator interface 525, Map.Entry interface 526
References and resources 527
Java and JavaBeans 527
Active X 529
Resources 529
Magazines 529, Java related web sites 530, News groups 530
index 531