Business Objects and Data Sources > Shelves and Cards > LEDs > Creating an LED with the API

This section shows how to create an LED using the API and how to add it to the data source.

When you create an LED with the API, you must provide its type, which can be set through the constructor or through the setAttributeValue method; the following sample shows how to create an LED of type Circular:

How to Create an LED with the API
List objects = new ArrayList();
// create shelf identified as myShelf
IltShelf s1 = new IltShelf("myShelf");
s1.setSlotSizes(2,50,1,100);
objects.add(s1);
 
// create card
IltCard c1 = new IltCard(new IltOSIObjectState(), "card 1");
c1.setPosition(new IlpShelfItemPosition(0, 0, 1, 1));
objects.add(c1);
 
// create card item
IltLed l1 = new IltLed("myLed");
l1.setType(IltLed.Type.Circular);
l1.setPosition(new IlpRelativePoint(25,85));
objects.add(l1);
 
// add all objects to data source
datasource.addObjects(objects);

The result looks like this:

images/ledwithapi101.gif

Figure 8.14 A Shelf Containing a Card with an LED