Java Reference
In-Depth Information
Example 14-9 shows a customizer for our YesNoPanel bean. This customizer dis-
plays a panel that has the same layout as a YesNoPanel , but it substitutes a
TextArea object for the message display and three TextField objects for the three
buttons that the dialog can display. These text entry areas allow the user to enter
values for the messageText , yesLabel , noLabel , and cancelLabel properties. Fig-
ure 14-3 shows this customizer panel displayed within a dialog box created by the
beanbox program. Again, note that the Done button is part of the beanbox dialog,
not part of the customizer itself.
Figure 14−3. The customizer dialog for the YesNoPanel bean
Example 14−9: YesNoPanelCustomizer.java
package com.davidflanagan.examples.beans;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
/**
* This class is a customizer for the YesNoPanel bean. It displays a
* TextArea and three TextFields where the user can enter the main message
* and the labels for each of the three buttons. It does not allow the
* alignment property to be set.
**/
public class YesNoPanelCustomizer extends Panel
implements Customizer, TextListener
{
protected YesNoPanel bean; // The bean being customized
protected TextArea message; // For entering the message
protected TextField fields[]; // For entering button text
// The bean box calls this method to tell us what object to customize.
// This method will always be called before the customizer is displayed,
// so it is safe to create the customizer GUI here.
public void setObject(Object o) {
bean = (YesNoPanel)o;
// save the object we're customizing
// Put a label at the top of the panel.
this.setLayout(new BorderLayout());
this.add(new Label("Enter the message to appear in the panel:"),
"North");
Search WWH ::




Custom Search