Dropping Beans on BeanBox

Let’s add a Bean to the BeanBox form. Select the ExplicitButton Bean from the toolbox and then click on the spot on the form where you want to place it. When a Bean is added to the form it is shown with a hatched border around it. This border indicates that the Bean is selected. Figure 7.4 shows the BeanBox form with an instance of the ExplicitButton currently selected. You can also use this border to move the Bean around on the form, or to resize it if the Bean supports that operation. When you want to select a Bean on the form you usually have to click just outside it, where the hatched border would be. Since the border isn’t shown for unselected Beans, you’ll have to guess where it is (just around the perimeter of the Bean). Some Beans allow you to select them by clicking anywhere within their border, but most do not. This is a bit of a nuisance, but you’ll get the hang of it.

A button in BeanBox

Figure 7-4. A button in BeanBox

You can remove the selected Bean from the form by selecting Cut from the Edit menu. When the Bean is removed, no other Bean on the form is selected. In some cases you may be able to remove the currently selected Bean from the form by pressing the DEL key. This doesn’t seem to work all the time, particularly for Beans that react to keyboard events. The safe bet here is to use the menu.

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.