borland.jbcl Packages borland.jbcl Class Hierarchy borland.jbcl.control
java.lang.Object +----java.awt.Component +----java.awt.Choice +----borland.jbcl.view.ChoiceView +----borland.jbcl.control.ChoiceControl
Variables Constructors Properties Methods Event Listeners
Implements AccessListener, DataChangeListener, NavigationListener, SingletonModel, SingletonModelListener, WritableSingletonModel, BlackBox, SingletonView, ItemSelectable, MenuContainer, ImageObserver, Serializable, EventListener
ChoiceControl is a drop-down menu of choices. The current selection is visible.
Example
// After selecting an animal name from the choice menu, the name appears in
// the text field.
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.control.*;
import borland.jbcl.layout.*;
public class ChoiceEx {
public ChoiceEx() {
ChoiceFrame frame = new ChoiceFrame();
frame.pack();
frame.setVisible(true);
}
static public void main(String[] args) {
new ChoiceEx();
}
}
class ChoiceFrame extends DecoratedFrame {
BevelPanel bev = new BevelPanel();
ChoiceControl choiceCtrl = new ChoiceControl();
TextFieldControl textFieldControl = new TextFieldControl();
public ChoiceFrame() {
this.setTitle("Animals");
choiceCtrl.setItems(new String[] {"Koalla", "Monkey", "Lark", "Puffin"});
this.add(bev);
bev.add(choiceCtrl, new XYConstraints(30, 10, -1, -1));
bev.add(textFieldControl, new XYConstraints(0, 50, 125, -1));
textFieldControl.setText("Koalla");
choiceCtrl.addItemListener(new ChoiceControlItemAdapter(this));
}
void choiceControlItemStateChanged(ItemEvent itemEvent) {
textFieldControl.setText((String)choiceCtrl.get());
}
}
class ChoiceControlItemAdapter implements java.awt.event.ItemListener {
ChoiceControlItemAdapter(ChoiceFrame choiceframe) {
this.choiceframe = choiceframe;
}
ChoiceFrame choiceframe;
public void itemStateChanged(ItemEvent itemEvent) {
choiceframe.choiceControlItemStateChanged(itemEvent);
}
}
public ChoiceControl()Constructs a ChoiceControl with default property values.
public String getColumnName() public void setColumnName(java.lang.String newColumnName)The columnName property identifies a column of the specified borland.jbcl.dataset.DataSet object to drive the ChoiceControl's selection. Sets the model to SingletonDataSetManager using the specified column of the specified dataset.
public DataSet getDataSet() public void setDataSet(borland.jbcl.dataset.DataSet newDataSet)The dataSet property specifies a borland.jbcl.dataset.DataSet object to drive the ChoiceControl's selection.
public void setModel(borland.jbcl.model.SingletonModel sm)Checks for a recursive model, then calls borland.jbcl.view.ChoiceView.setModel(SingletonModel), which specifies the model object required for access to a list of choices. ChoiceView requires a VectorModel object.
public void addNotify()Calls java.awt.Choice.html#addNotify() to create the ChoiceControl's peer. This peer allows changing the look of the Choice without changing its functionality. Initializes the choice control if not already initialized. Opens the DataSet supplying this choice control.
Overrides: java.awt.Choice.addNotify()
public void setItems(borland.jbcl.dataset.DataSet dataSet, java.lang.String columnName)Populates the choice control using the strings from the specified column of the specified DataSet.
Parameters:
public synchronized void addComponentListener(java.awt.event.ComponentListener l) public synchronized void removeComponentListener(java.awt.event.ComponentListener l)
public synchronized void addFocusListener(java.awt.event.FocusListener l) public synchronized void removeFocusListener(java.awt.event.FocusListener l)
public synchronized void addItemListener(java.awt.event.ItemListener l) public synchronized void removeItemListener(java.awt.event.ItemListener l)
public synchronized void addKeyListener(java.awt.event.KeyListener l) public synchronized void removeKeyListener(java.awt.event.KeyListener l)
public void addModelListener(borland.jbcl.model.SingletonModelListener listener) public void removeModelListener(borland.jbcl.model.SingletonModelListener listener)
public synchronized void addMouseListener(java.awt.event.MouseListener l) public synchronized void removeMouseListener(java.awt.event.MouseListener l)
public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener l) public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener l)