O'Reilly logo

JavaBeans Unleashed by Rick Leinecker, Dr. Donald Doherty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending Java's Canvas Class

The Canvas class, which is part of the java.awt package, makes an excellent base class for control beans. Creating a JavaBeans control from Java's Canvas class is simple. In this section, you write a bean that extends the Canvas class and can display any supported image file. Users type the name of the image file into the bean's property sheet, presented by the BeanBox or an application builder program, and the image file is loaded and displayed by the bean. In other words, this bean has an image filename property.

The code for the new bean class, named Picture, is in Listing 7.1. There are a couple of key elements in the Picture class code. All of the code used to load the image is in the getImageFilename() accessor ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required