*************************************************************************
*  Copyright (C) 1996-1997 by NEURON DATA Inc.                          *
*  All Rights Reserved.                                                 *
*                                                                       *
# @(#)BEANS.txt	2.2 97/03/27
*************************************************************************



                             Supporting Java Beans

    Java Beans allows an interface builder to look at a Beans class and
    determine the Properties, Events and Methods it supports.  Java Beans
    also contains a number of other related technologies (Drag and Drop,
    serialization, etc.) but the most critical portion of the Java
    Beans API as far as communicating with Java Beans objects is concerned
    is the Property/Event/Method model.

    The examples directory contains some examples of handling events and
	setting properties using the MCT and Java Beans model.

Properties

    A Beans class supports setting Properties with set and get methods
    such as:

        void setTopShadowColor(Color value)
        Color getTopShadowColor();

    If you are familiar with the API for the MCT, you will know that
    this may be performed with:

        obj.setValue("topShadowColor", value);
        Color c = (Color)obj.getValue("topShadowColor");

    Both methods of setting global Properties are supported by this
    release of the MCT.  If you use an interface builder which supports Java
    Beans, it will use the get and set methods of the classes to deal with
    Properties.

    You should still use resources to set sub-resources such as resources
    for individual tabs (in the TabPanel) and for rows/columns/cells in the
    Grid or Tree.

Events

    To fully support the Java Beans API in your code, you should move to
    the listener based event model which is used to receive events
    in Java Beans.  In MCT3.1, the interface objects need to 
    use the JDK 1.1 event mechanism (listener based event model).
    You cannot use the JDK1.02 event handling mechanism (handleEvent() 
    or action()). If you use previous version of MCT, you might use
    JDK1.02 event model to handle MCT objects events.
    
    Changing to the listener based model of receiving events is probably
    the only change you need to make to your existing JDK 1.02 code which
    uses the MCT to move to Java Beans.  This toolkit interfaces to the
    other parts of Java Beans to support other portions of the Java Beans
    specification.

    Changing your code to use the Beans event model should be simplified
    since the MCT uses MlGridEvent/MlTreeEvent events to handle events
    from the Grid and the Tree.  Your code using the JDK 1.02 event
    model might look like:

    class MyPanel extends Panel
        {
        public boolean handleEvent(Event event)
            {
            MlTreeEvent treeEvent;

            if (event.target == tree && event.id == MlTreeEvent.EXPAND_ROW)
                {
                treeEvent = (MlTreeEvent)event;
                expandRow(treeEvent.row);    
                return true;
                }
            return super.handleEvent(event);
            }

    To follow Java Beans this should change to something like:

    class MyPanel extends Panel implements MlTreeListener
        {
        public MyPanel()
            {
            tree = ....
            tree.addMlTreeListener(this);    
            }

        public void onTreeEvent(MlTreeEvent event)
            {
            if (event.getType() == MlTreeEvent.EXPAND_ROW)
                expandRow(treeEvent.getRow());
            }
        }

    notice that your logic doesn't change and the event object you deal
    with stays basically the same.  You should access the event member
    variables through its accessor methods instead of just accessing the
    public members directly for Java Beans compatibility.

Methods

    There were no changes to method calls required to support Java Beans.

