The Microline Component Toolkit 3.1 provides JDK 1.1 support to: JDK 1.1 Support
Note: The /EXAMPLES directory contains code samples for setting properties and handling events using Microline Component Toolkit 3.1 and JDK 1.1. However, for this release of Microline Component Toolkit, the examples in the documentation do not use these features. Please refer to the code samples in the /EXAMPLES directory of the Toolkit for information.
Note: The Microline Component Toolkit 3.1 API is not compatible with versions of JDK earlier than Version 1.1.
Note: Microline Component Toolkit applets are only compatible with browsers that support the JDK 1.1 specification. This includes Hot Java, as well as upcoming releases of Netscape Navigator and Internet Explorer.
A JDK 1.1 class supports setting and getting properties with "set" and "get" methods such as:
void setTopShadowColor(Color value) Color getTopShadowColor()
Earlier versions of JDK and the Microline Component Toolkit supported an alternate resource method:
obj.setValue("topShadowColor", value);
Color c = (Color)obj.getValue("topShadowColor");
Microline Component Toolkit 3.1 supports both the property and the resource methods, including using the "get" and "set" methods of the classes when dealing with properties of resources.
Note: Microline Component Toolkit 3.0e also supported both of these methods.
Note: To set subresources, such as individual tabs in a TabPanel or resource rows/columns/cells in a Grid or Tree, continue to use the resource mechanism. For example:
MlResources res= new MlResources();
res.add("row",3);
res.add("column",3);
res.add("cellType",MlGrid.IMAGE_CELL);
grid.setValues(res);
Microline Component Toolkit 3.1 supports the JDK 1.1 implementation of listener-based event models. Using these models results in code that is more efficient than using the former event-handling mechanism.
Note: For JDK 1.1 compatibility, you access event-member variables through the accessor methods for the event. Do not directly access the data members.
Double-clicking a row or pressing the ENTER/RETURN key generates a MlGridEvent of the type SELECT_ACTIVATED. You can determine if the event is of this type by calling the getType() method of the MlGridEvent class.
You handle grid events using MlGridListener, which is a subclass of EventListener. You add MlGridListener to the MlGrid by calling addMlGridListener().
To use MlGridListener, you need to implement the MlGridListener interface. MlGridListener defines one method: onGridEvent(MlGridEvent).
Alternately, you can handle an event by overriding processEvent() or processMlGridEvent().
Unlike with other Java AWTEvents, it is unnecessary call enableEvents() to handle MlGridEvent by processEvent().
The following code fragments demonstrate changing from the old event-handling model to the new listener-based event-handling model for MlGrid. The event-handling logic and the event object references remain the same in both examples.
public class grid1 extends Applet implements
MlGridListener
{
MlGrid grid;
public void init()
{
MlResources res;
Dimension prefSize;
grid = new MlGrid();
res = new MlResources();
add(grid);
grid.addMlGridListener(this);
}
public void onGridEvent(MlGridEvent event)
{
if (event.getTypeD() ==
MlGridEvent.SELECT_ACTIVATED)
{
System.out.println("row " + event.row
+ "activated");
}
}
}
The following modified example supports the JDK 1.1 listener-based event model using Microline Component Toolkit 3.1:
public boolean action(Event event, Object obj)
{
if (event.target == grid)
{
MlGridEvent e = (MlGridEvent)event;
System.out.println("row " + e.row + "
activated");
}
return super.action(event, obj);
}
}
MlTreeEvent inherits from MlGridEvent. It adds the capability to handle two new event types: COLLAPSE_ROW and EXPAND_ROW.
You handle tree events using MlTreeListener, which is a subclass of EventListener. You add MlTreeListener to the MlTree by calling addMlTreeListener.
Alternately, you can handle event processing by overriding processEvent() or processMlTreeEvent().Unlike with other Java AWTEvents, you do not need to call enableEvents() to handle MlTreeEvent by processEvent().
Note: MlTreeEvent is always enabled for MlTree.
The following code fragments demonstrate changing from the old event-handling model to the new listener-based event handling model for MlTree. The event-handling logic and the event object references remain the same in both examples.
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);
}
}
The following modified example supports the JDK 1.1 listener-based event model using Microline Component Toolkit 3.1:
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());
}
}
MlTabPanelEvent inherits from AWTEvent.
You handle TabPanel events using MlTabPanelListener, which is a subclass of EventListener. You add MlTabPanelListener to the MlTabPanel by calling addMlTabPanelListener().
Alternately, you can handle event processing by overriding processEvent() or processMlTabPanelEvent(), a subclass of the MlTabPanel class. These are subclasses of the MlTree class.
Note: MlTreeEvent is always enabled for MlTree.
The following code is a complete example that uses the MlTabPanelListener.
import java.awt.*;
import mlsoft.mct.*;
import java.applet.Applet;
class MyTabPanel extends MlTabPanel
{
public void setFocusTab(int num)
{
setFocusTab(_tabs[num], null);
}
}
public class tabpanel1 extends Applet implements
MlTabPanelListener
{
MyTabPanel tabPanel;
public Insets insets()
{
return new Insets(10, 10, 10, 10);
}
public void init()
{
int i;
setLayout(new BorderLayout());
setBackground(new Color(192, 192, 192));
tabPanel = new MyTabPanel();
tabPanel.setValue("marginWidth", 4);
tabPanel.setFocusTab(2);
for (i = 1; i <= 3; i++)
tabPanel.add("Tab " + i, new Label("Page "+i,
Label.CENTER));
add("Center", tabPanel);
tabPanel.addMlTabPanelListener(this);
}
public void onTabSelect(MlTabPanelEvent event)
{
System.out.println("Tab selected");
}
}