Java Reference
In-Depth Information
Figure 14−1. The YesNoPanel bean in beanbox
Example 14−3: YesNoPanel.java
package com.davidflanagan.examples.beans;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
/**
* This JavaBean displays a multi-line message and up to three buttons. It
* fires an AnswerEvent when the user clicks on one of the buttons
**/
public class YesNoPanel extends Panel {
// Properties of the bean.
protected String messageText; // The message to display
protected Alignment alignment; // The alignment of the message
protected String yesLabel;
// Text for the yes, no, & cancel buttons
protected String noLabel;
protected String cancelLabel;
// Internal components of the panel
protected MultiLineLabel message;
protected Button yes, no, cancel;
/** The no-argument bean constructor, with default property values */
public YesNoPanel() { this("Your\nMessage\nHere"); }
public YesNoPanel(String messageText) {
this(messageText, Alignment.LEFT, "Yes", "No", "Cancel");
}
/** A constructor for programmers using this class "by hand" */
public YesNoPanel(String messageText, Alignment alignment,
String yesLabel, String noLabel, String cancelLabel)
Search WWH ::




Custom Search