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
public UIColumnViewer();
Creates a column viewer control with no column headers or content.
public UIColumnViewer(Object columns[], IUIComponent list);
Creates a column viewer control using an array of objects for headers and a component list for content.
Parameter | Description |
columns
| The array of column objects.
|
list
| The component list.
|
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.
Parameter | Description |
e
| The event posted to the control.
|
o
| The object that posted the event.
|
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.
Parameter | Description |
columns
| An array of objects to add to the column viewer.
|
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.
Parameter | Description |
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.
|
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.
Parameter | Description |
columns
| An array of objects to add to the column viewer.
|
constraints
| The layout constraints of the content container for the column viewer.
|
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.
Parameter | Description |
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.
|
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.
Parameter | Description |
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.
|
index
| The position of the row object when it is added to the list.
|
Overrides:
add(IUIComponent,Object,int) in UIScrollViewer.
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.
Parameter | Description |
l
| The action listener to be added.
|
See Also: removeActionListener
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.
Parameter | Description |
l
| The item listener to be added.
|
See Also: removeItemListener
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.
Parameter | Description |
index
| The zero-based index of the column.
|
Exceptions:
IllegalArgumentException
if an invalid index is specified.
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.
Parameter | Description |
i
| The zero-based index of the column.
|
Exceptions:
IllegalArgumentException
if an invalid index is specified.
See Also: setWidth
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
public void moveColumn(int from, int to);
Moves a column from one location to another.
Return Value:
No return value.
Parameter | Description |
from
| The zero-based index that identifies the column to move.
|
to
| The zero-based index that identifies where the column is moving to.
|
protected void processActionEvent(UIActionEvent e);
Processes action events.
Return Value:
No return value.
Parameter | Description |
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
protected void processEvent(UIEvent e);
Processes the specified event.
Return Value:
No return value.
Parameter | Description |
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.
When overriding processEvent, call the super method processEvent to ensure the default event processing continues normally.
protected void processItemEvent(UIItemEvent e);
Processes item events.
Return Value:
No return value.
Parameter | Description |
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
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.
Parameter | Description |
l
| The action listener to be removed.
|
See Also: addActionListener
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.
Parameter | Description |
l
| The item listener to be removed.
|
See Also: addItemListener
public void setColumns(Object columns[]);
Adds an array of columns to the component.
Return Value:
No return value.
Parameter | Description |
columns
| The array of columns to set.
|
public void setWidth(int index, int width);
Sets the width of the column at the specified index.
Return Value:
No return value.
Parameter | Description |
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
public void setWidths(int width);
Sets the widths of all columns to the specified width.
Return Value:
No return value.
Parameter | Description |
width
| The new width (in pixels) for each column.
|
Exceptions:
IllegalArgumentException
if an invalid index is specified.
See Also: getWidths
public void setWidths(int widths[]);
Sets all the column widths to the specified widths.
Return Value:
No return value.
Parameter | Description |
widths
| The array of new widths (in pixels) for each column.
|
Exceptions:
IllegalArgumentException
if an invalid index is specified.
See Also: getWidths