borland Packages  Class Hierarchy  jbcl.view Package  Index 

CustomItemListener interface

java.util.EventListener
   +----borland.jbcl.view.CustomItemListener

About the CustomItemListener interface

Methods  
An implementor of the CustomItemListener interface listens to a view manager receive requests for item painters and item editors.

When a request is made, an event is fired to allow a listener (an implementor of this interface) to customize the properties of the ItemPaintSite using the CustomPaintSite interface. The listener has access to all contextual information in the event call, including address, data, and state information. The listener can analyze any of this information (or none of it) to determine what custom changes to make to the CustomPaintSite.

These events are commonly used, for example, to make all negative numbers apear red on a JBCL component such as a grid, and to make even numbered rows to have a gray background. The following is an example event handler that shows how to do this:

public void customizeItem(Object address, Object data, int state, CustomPaintSite)
(
  //make the foreground red if the data is numeric and negative
  if (data instanceof Number)
  (
    int value = ((Number)data).intValue();
	if (value < 0)
	site.setForeground(Color.red);
  )
  // make all even numbered rows have a light gray background
  if (address instanceof MatrixLocation)
  (
    int row = ((MatrixLocation)address).row;
	if (row % 2 == 0)
	site.setBackground(Color.lightGray);
  )
 )
 

CustomItemListener methods

Methods defined in this interface


CustomItemListener methods

customizeItem(java.lang.Object, java.lang.Object, int, borland.jbcl.model.CustomPaintSite)

  public void customizeItem(java.lang.Object address, java.lang.Object data, int state, borland.jbcl.model.CustomPaintSite site)
This event is triggered when a view manager is asked for an item painter to paint an item within a component, or when it is asked for an item editor to edit a component A listener can set the properties of the CustomPaintSite based on the address, data, state information, or whatever is needed.

Parameters:

address
The address object of the data item. This will be null for Singleton, an integer for Vector, a MatrixLocation for Matrix, or a GraphLocation for Graph.
data
The data object from the model.
state
The state bitmaks information (FOCUSED, SELECTION, and so on).
site
The CustomPaintSite that allows the listener to set the background, foreground, font, alignment, and margins around the particular item being painted (or edited).