FileDocCategorySizeDatePackage
AttributePanel.javaAPI DocExample6239Sat Sep 12 03:01:00 BST 1998borland.samples.jbcl.checkboxcontrol

AttributePanel

public class AttributePanel extends BevelPanel
A BevelPanel based attribute panel class. This produces a generic attribute page for displaying attributes/properties and their associated values
version
1.0, 06/10/97
author
Borland Development Team

Fields Summary
GridLayout
gridLayout1
GridControl
gridControl1
BasicMatrixContainer
bmc
ColumnView[]
tempColumns
Constructors Summary
public AttributePanel()
Constructor the attribute panel and it's UI elements


             
    
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  
Methods Summary
public voidaddItem(java.lang.String name, java.lang.String value)
Add an item name and string value

param
name The name of the item to insert
param
value The initial string value to set the item to

    // Insert a new row into the container
    bmc.addRow();

    // Add the item at the end
    bmc.set(bmc.getRowCount()-2, 0, name);
    bmc.set(bmc.getRowCount()-2, 1, value);
  
public voidaddItem(java.lang.String name, boolean state)
Add an item name and boolean value

param
name The name of the item to insert
param
state The initial boolean value to set the item to

    this.addItem(name, (state ? "True" : "False"));
  
public voidjbInit()
UI elements of the attribute panel

    this.setBevelInner(BevelPanel.FLAT);
    tempColumns[0] = new ColumnView();
    tempColumns[0].setAlignment(Alignment.LEFT | Alignment.MIDDLE);
    tempColumns[0].setCaption("Attribute");
    tempColumns[0].setWidth(100);
    tempColumns[1] = new ColumnView();
    tempColumns[1].setAlignment(Alignment.LEFT | Alignment.MIDDLE);
    tempColumns[1].setCaption("Value");
    tempColumns[1].setWidth(305);
    gridControl1.setColumnViews(tempColumns);
    gridControl1.setDragSubfocus(false);
    gridControl1.setEditInPlace(false);
    gridControl1.setGridVisible(false);
//    gridControl1.setHScrollVisible(false);
    gridControl1.setResizableRows(false);
    gridControl1.setRowHeaderVisible(false);
    gridControl1.setSelectRow(true);
    gridControl1.setShowFocus(false);
//    gridControl1.setVScrollVisible(false);
    gridControl1.setModel(bmc);
    gridControl1.setViewManager(new BasicViewManager(new TextItemPainter(), new TextItemEditor()));
    this.setLayout(gridLayout1);
    this.add(gridControl1, null);
  
public voidremoveItem(java.lang.String name)
Loop through the container. This will remove all occurances of the item just in case there are duplicates. Use removeItem(int) to remove only a specific item.

param
name The string representation of the item to remove

    for (int i=0;i<bmc.getRowCount();i++) {
      if (bmc.get(i, 0).equals(name) == true)
        bmc.removeRow(i);
    }
  
public voidremoveItem(int index)
This will remove only the item specified in the index paramater

param
index The index of the item to remove (base 1)

    bmc.removeRow(index);
  
public voidsetValue(java.lang.String name, java.lang.String value)
Loop through the container. This will set all occurances of the item just in case there are duplicates. Use setItem(int) to set only a specific item. If the specified item does not exist, it is added to the display.

param
name The string representation of the item to modify
param
value The string value to set the specified item to

    boolean foundItem = false;
    if (bmc.getRowCount() > 1) {
      for (int i=0;i<bmc.getRowCount()-1;i++) {
        if (bmc.get(i, 0).equals(name) == true) {
          foundItem = true;
          bmc.set(i, 1, value);
        }
      }
    }
    if (foundItem == false)
      this.addItem(name, value);
  
public voidsetValue(int index, boolean state)
This will set only the item specified in the index paramater

param
index The index of the item to set (base 1)
param
state The boolean value to set the specified item to

    String value;
    this.setValue(index, (state ? "True" : "False"));
  
public voidsetValue(int index, java.lang.String value)
This will set only the item specified in the index paramater

param
index The index of the item to set (base 1)
param
value The string value to set the specified item to

    bmc.set(index, 1, value);
  
public voidsetValue(java.lang.String name, boolean state)
Loop through the container. This will set all occurances of the item just in case there are duplicates. Use setItem(int) to set only a specific item. If the specified item does not exist, it is added to the display.

param
name The string representation of the item to modify
param
state The boolean value to set the specified item to

    this.setValue(name, (state ? "True" : "False"));