Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


Class UIColumnViewer

public class UIColumnViewer extends UIScrollViewer
{
  // Constructors
  public UIColumnViewer();
  public UIColumnViewer(Object columns[], IUIComponent list);

  // Methods
  public boolean action(Event e, Object o);
  public IUIComponent add(Object columns[]);
  public IUIComponent add(Object columns[], int index);
  public IUIComponent add(Object columns[], Object constraints);
  public IUIComponent add(Object columns[], Object constraints, int
        index);
  public IUIComponent add(IUIComponent comp, Object constraints,
        int index);
  public synchronized void addActionListener(IUIActionListener l);
  public synchronized void addItemListener(IUIItemListener l);
  public int getOrderIndex(int index);
  public int getWidth(int i);
  public int[] getWidths();
  public void moveColumn(int from, int to);
  protected void processActionEvent(UIActionEvent e);
  protected void processEvent(UIEvent e);
  protected void processItemEvent(UIItemEvent e);
  public synchronized void removeActionListener(
        IUIActionListener l);
  public synchronized void removeItemListener(IUIItemListener l);
  public void setColumns(Object columns[]);
  public void setWidth(int index, int width);
  public void setWidths(int width);
  public void setWidths(int widths[]);
}

This class implements a scrollable column viewer control. UIColumnViewer extends UIScrollViewer to display columns of data, either with or without headers for the columns. IUIComponent objects can be added to the UIColumnViewer and the UIColumnViewer will perform setting the layout of all UIRow elements contained within the IUIComponent being added.

When creating a UIColumnViewer object, you specify the column headers and the content component. Typically, the content component is a UIList object, but can also be other containers, such as UITree objects.

The following example shows how to construct and work with UIColumnViewer objects.

// Set the layout manager for the current container.
setLayout(new BorderLayout());
setFont(new Font("Helvetica", 0, 14));

// Create column headings. This is typically an array of
// Objects, Strings, or UIColumnHeader objects. In this
// example, the array passed to the column viewer is an
// array of UIColumnHeader objects, each with a different
// attribute.
UIColumnHeader headings[] = { (new UIColumnHeader("Expenses")),
               new UIText("Inventory", UIStatic.CENTERED),
               new UIGraphic(myImage, UIStatic.RIGHT),
               new UIText("Profit", UIStatic.BOTTOMRIGHT) };

// Create a list object for the column viewer's content. 
// This UIList object is populated with a generic fillList() method. 
list = new UIList();
fillList(list, rows[]);

// Create a column viewer control with the previously 
// specified headings and list objects.
cl = new UIColumnViewer(headings, list);

// Add the column viewer to the container with a 
// centered alignment.
add("Center", cl);

With the add methods, you can add Object arrays and UI components to the column viewer directly. The UIColumnViewer handles the layout of the objects, but you can specify constraints, as well as an insertion point where the row of objects is added to the viewer contained list. All the add methods return the actual object added to the list, regardless of the columns parameter type. Typically, this is a UIRow object.


// You can still add objects to the column viewer
// once it has been created.

 objectArray[0] = (new UIGraphic(dirImage, UIStatic.LEFT));
 objectArray[1] = names[file.type];
 objectArray[2] = file.lastModified();
 objectArray[3] = "" + file.size + " bytes";
cl.add(objectArray, -1);

UIRow forgotOne = new UIRow(theLastRow);
// ...
cl.add(forgotOne, UIScrollViewer.CONTENT, -1);
UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UIPanel
        |
        +--UIScrollViewer
          |
          +--UIColumnViewer

Constructors

UIColumnViewer

public UIColumnViewer();

Creates a column viewer control with no column headers or content.

UIColumnViewer

public UIColumnViewer(Object columns[], IUIComponent list);

Creates a column viewer control using an array of objects for headers and a component list for content.

ParameterDescription
columns The array of column objects.
list The component list.

Methods

action

public boolean action(Event e, Object o);

Handles column viewer actions. Specifically, this method handles the resizing operations for content columns when a column header is moved or resized.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
e The event posted to the control.
o The object that posted the event.

add

public IUIComponent add(Object columns[]);

Adds an Object array to the end of a UIColumnViewer object's contained list.

Return Value:

Returns the UIRow object added to the list that contains the given objects as the columns in the row.

ParameterDescription
columns An array of objects to add to the column viewer.

add

public IUIComponent add(Object columns[], int index);

Adds an Object array to the UIColumnViewer object's contained list, at a specified index.

Return Value:

Returns the UIRow object added to the list that contains the given objects as the columns in the row.

ParameterDescription
columns An array of objects to add to the column viewer.
index The position of the row object when added to the list. Set this value to -1 if the row is added to the end of the list.

add

public IUIComponent add(Object columns[], Object constraints);

Adds an Object array to the end of a UIColumnViewer object's contained list.

Return Value:

Returns the UIRow object added to the list that contains the given objects as the columns in the row.

ParameterDescription
columns An array of objects to add to the column viewer.
constraints The layout constraints of the content container for the column viewer.

add

public IUIComponent add(Object columns[], Object constraints, int index);

Adds an Object array to the UIColumnViewer object's contained list, at a specified insertion index.

Return Value:

Returns the UIRow object added to the list that contains the given objects as the columns in the row.

ParameterDescription
columns An array of objects to add to the column viewer.
constraints The layout constraints of the content container for the column viewer.
index The position of the row object when added to the list.

add

public IUIComponent add(IUIComponent comp, Object constraints, int index);

Adds an IUIComponent to the UIColumnViewer object's contained list, at a specified insertion index.

Return Value:

Returns the actual component added. Typically, this is a UIRow object.

ParameterDescription
comp A component to add to the column viewer. Typically, this is some type of list object.
constraints The layout constraints of the content container for the column viewer. This can be one of the following constraints.
CONTENT SCROLL_VERT SCROLL_HORIZ SCROLL_CORNER
HEADER_VERT HEADER_HORIZ HEADER_CORNER
index The position of the row object when it is added to the list.

Overrides:

add(IUIComponent,Object,int) in UIScrollViewer.

addActionListener

public synchronized void addActionListener(IUIActionListener l);

Adds the specified action listener. The listener receives all action events generated for the control.

Return Value:

No return value.

ParameterDescription
l The action listener to be added.

See Also: removeActionListener

addItemListener

public synchronized void addItemListener(IUIItemListener l);

Adds the specified item listener. The listener receives all item events generated for the control. (Item events are generated when the state of an item changes.)

Return Value:

No return value.

ParameterDescription
l The item listener to be added.

See Also: removeItemListener

getOrderIndex

public int getOrderIndex(int index);

Retrieves the order of the column at the specified index.

Return Value:

Returns the zero-based order of the column.

ParameterDescription
index The zero-based index of the column.

Exceptions:

IllegalArgumentException if an invalid index is specified.

getWidth

public int getWidth(int i);

Retrieves the current width of the column at the specified index.

Return Value:

Returns the width (in pixels) of the specified column.

ParameterDescription
i The zero-based index of the column.

Exceptions:

IllegalArgumentException if an invalid index is specified.

See Also: setWidth

getWidths

public int[] getWidths();

Retrieves the current widths for all the columns.

Return Value:

Returns an array of the widths (in pixels) for each of the columns.

Exceptions:

IllegalArgumentException if an invalid index is specified.

See Also: setWidths

moveColumn

public void moveColumn(int from, int to);

Moves a column from one location to another.

Return Value:

No return value.

ParameterDescription
from The zero-based index that identifies the column to move.
to The zero-based index that identifies where the column is moving to.

processActionEvent

protected void processActionEvent(UIActionEvent e);

Processes action events.

Return Value:

No return value.

ParameterDescription
e The action event.

Remarks:

This method is called by processEvent and dispatches the event to a registered action listener. When overriding this method, call the super method processActionEvent to ensure the default event processing continues normally.

See Also: addActionListener

processEvent

protected void processEvent(UIEvent e);

Processes the specified event.

Return Value:

No return value.

ParameterDescription
e The event.

Remarks:

This method is automatically invoked if a listener has been registered through a call to addXXXListener. Depending on the type of event, processEvent calls one of the following methods.

Event type Method called
action event processActionEvent
item event processItemEvent
container event processContainerEvent (inherited through UIStateContainer)
focus event processFocusEvent (inherited through UIStateContainer)
key event processKeyEvent (inherited through UIStateContainer)
mouse event processMouseEvent (inherited through UIStateContainer)
mouse motion event processMouseMotionEvent (inherited through UIStateContainer)

When overriding processEvent, call the super method processEvent to ensure the default event processing continues normally.

processItemEvent

protected void processItemEvent(UIItemEvent e);

Processes item events.

Return Value:

No return value.

ParameterDescription
e The item event.

Remarks:

This method is called by processEvent and dispatches the event to a registered item listener. When overriding this method, call the super method processItemEvent to ensure the default event processing continues normally.

See Also: addItemListener

removeActionListener

public synchronized void removeActionListener(IUIActionListener l);

Removes the specified action listener. The listener no longer receives the control's action events.

Return Value:

No return value.

ParameterDescription
l The action listener to be removed.

See Also: addActionListener

removeItemListener

public synchronized void removeItemListener(IUIItemListener l);

Removes the specified item listener. The listener no longer receives the control's item events.

Return Value:

No return value.

ParameterDescription
l The item listener to be removed.

See Also: addItemListener

setColumns

public void setColumns(Object columns[]);

Adds an array of columns to the component.

Return Value:

No return value.

ParameterDescription
columns The array of columns to set.

setWidth

public void setWidth(int index, int width);

Sets the width of the column at the specified index.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the column.
width The new width (in pixels) for the column.

Exceptions:

IllegalArgumentException if an invalid index is specified.

See Also: getWidth

setWidths

public void setWidths(int width);

Sets the widths of all columns to the specified width.

Return Value:

No return value.

ParameterDescription
width The new width (in pixels) for each column.

Exceptions:

IllegalArgumentException if an invalid index is specified.

See Also: getWidths

setWidths

public void setWidths(int widths[]);

Sets all the column widths to the specified widths.

Return Value:

No return value.

ParameterDescription
widths The array of new widths (in pixels) for each column.

Exceptions:

IllegalArgumentException if an invalid index is specified.

See Also: getWidths

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.