borland.jbcl Packages  borland.jbcl Class Hierarchy  borland.jbcl.control 

ChoiceControl component

java.lang.Object
   +----java.awt.Component
           +----java.awt.Choice
                   +----borland.jbcl.view.ChoiceView
                           +----borland.jbcl.control.ChoiceControl

About the ChoiceControl component

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);
    }
}

ChoiceControl variables

Variables implemented in java.awt.Component

ChoiceControl constructors

ChoiceControl properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in borland.jbcl.view.ChoiceView

Properties implemented in java.awt.Choice

Properties implemented in java.awt.Component

Properties implemented in java.lang.Object

ChoiceControl methods

Methods implemented in this class

Methods implemented in borland.jbcl.view.ChoiceView

Methods implemented in java.awt.Choice

Methods implemented in java.awt.Component

Methods implemented in java.lang.Object

ChoiceControl event listeners


ChoiceControl constructors

ChoiceControl()

  public ChoiceControl()
Constructs a ChoiceControl with default property values.


ChoiceControl properties

columnName

 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.

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.

model

 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.


ChoiceControl methods

addNotify()

  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()

setItems(borland.jbcl.dataset.DataSet, java.lang.String)

  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:

dataSet
The data set to use to populate the choice control.
columnName
The column of dataSet to use.


ChoiceControl event listeners

This component is a source for the following event sets. For information on the standard AWT event sets, see Standard Java events. For information on the JBCL event sets, see Events in JBCL.

component

 public synchronized void addComponentListener(java.awt.event.ComponentListener l)
 public synchronized void removeComponentListener(java.awt.event.ComponentListener l)

focus

 public synchronized void addFocusListener(java.awt.event.FocusListener l)
 public synchronized void removeFocusListener(java.awt.event.FocusListener l)

item

 public synchronized void addItemListener(java.awt.event.ItemListener l)
 public synchronized void removeItemListener(java.awt.event.ItemListener l)

key

 public synchronized void addKeyListener(java.awt.event.KeyListener l)
 public synchronized void removeKeyListener(java.awt.event.KeyListener l)

model

 public void addModelListener(borland.jbcl.model.SingletonModelListener listener)
 public void removeModelListener(borland.jbcl.model.SingletonModelListener listener)

mouse

 public synchronized void addMouseListener(java.awt.event.MouseListener l)
 public synchronized void removeMouseListener(java.awt.event.MouseListener l)

mouseMotion

 public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener l)
 public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener l)