borland Packages Class Hierarchy jbcl.control Package Index
java.lang.Object +----java.awt.Component +----java.awt.Container +----com.sun.java.swing.JComponent +----com.sun.java.swing.JScrollPane +----borland.jbcl.view.GridView +----borland.jbcl.control.GridControl
Variables Constructors Properties Methods Event Listeners
Implements AccessListener, DataChangeListener, DataSetAware, NavigationListener, MatrixModel, MatrixSubfocusListener, WritableMatrixModel, BlackBox, HeaderListener, MatrixView, Accessible, ScrollPaneConstants, ImageObserver, MenuContainer, Serializable, EventListener
A GridControl displays data in a tabular form. The data can come from a data set or from the items property. It is a composite component that derives much of its behavior from GridView. GridControl gives you many options to customize how the data is displayed and edited.
If the grid is used as a data-aware control, the dataSet property is set to the data set containing the data. The user can then manipulate the data and post changes to the data set using the grid.
If the navigateWithDataSet property is true, navigating within the grid updates all data-aware controls connected to the same data set to the subfocus item in the grid.
If the grid is not connected to a data set, it retrieves its data from the items property. Specify the items to display in the grid using the dialog box property editor for the items property, which itself is a grid. By typing data values into the cells of the property editor grid, you create a two-dimensional array of strings the GridControl displays and the user can edit.
GridControl extends GridView. Several GridView properties control the editing behavior of GridControl. For example, editInPlace enables or disables cell editing, autoEdit determines whether the user must press F2, Ctrl+Enter, or double-click the cell to begin editing or whether editing begins when the user begins typing, and alwaysEdit determines whether an edit session begins when the subfocus moves to a new cell.
To prevent the user from editing the data, set readOnly to true.
GridControl has both a row and a column header, which are inherited from GridView. If the data comes from a data set, the column header contains the name of the columns or fields in the data set; otherwise, the column is simply identified by number. The row header displays the number of each row. The row and column headers can be hidden with the columnHeaderVisibleand rowHeaderVisible properties and their size can be changed by setting the columnHeaderHeight and rowHeaderHeight properties to new values. If the dataSet property is set and the sortOnHeaderClick property is true, clicking on a column header sorts the data in the column. Clicking the header again reverses the sort order.
The value of the defaultColumnWidth property is the column width for a new column inserted into the grid. The user can change the width of each column or row by dragging the header edge of the desired column or row if the resizableColumns and resizableRows property are true. The columnSizes property keeps the width of each column in a vector and the rowSizes property maintains a vector for the row heights.
Each column has a ColumnView class that maintains the attributes of the column. All the column views are kept in the columnViews property, which is an array of ColumnView classes. The user can modify these attributes for a single column at runtime using the right-click menu. Such attributes are background and foreground colors, font, and text alignment.
A GridControl can contain a fixed number of rows and columns, or a variable number of rows and columns that changes to meet the users needs. The rowCount and columnCount properties contains the number of rows and columns in the grid. If the variableColumns and variableRows properties are true, columns and rows can be added and deleted.
The user can use the right-click menu to add and delete columns and rows. The right-click, or context, menu is available only if the showPopup property is true.
You can specify how cells are selected in the GridControl. If multiSelect is true, the user can select multiple cells at a time instead of only one. To select multiple cells, drag the mouse cursor over the rows or use the Shift or Ctrl keys in combination with the arrow keys. Also the selectRow property enables an entire row to be selected when a cell within a row is clicked and selectColumn enables the selection of an entire column. dragSubfocus set to true allows the subfocus to follow from cell to cell as the mouse pointer is dragged over the grid. Clicking the button between the column and row header moves the subfocus to the home or top-left cell in the grid.
GridView defines several other properties that determine how the GridControl displays. For example, showVScroll and showHScroll determine whether scrollbars appear. gridLineColor sets the color of the lines between each cell and gridVisible determines whether the lines are visible or invisible.
If you connect the GridControl to a data set, you might consider adding a NavigatorControl to the container of the grid so that users can navigate through and edit and post data with the navigator.
protected String textureName
public GridControl()Creates a GridControl component.
public boolean isAutoInsert() public void setAutoInsert(boolean auto)
Stores whether to automatically insert a row. Inserts a blank data object when the GridControl is empty.
When focusGained is called, if the grid is not read-only and if there are variable rows, this method adds a row.
The default is value is true.
public String[] getColumnCaptions() public void setColumnCaptions(java.lang.String[] columnNames)Sets the column captions to the values in the passed array. If no columns exist (or the number of passed column captions is different than the number that exist), it creates ColumnViews, and a generic Column Header manager so that the given grid has a column for each entry in columnNames[] - and plugs in a new empty model into the grid (all data is lost).
public int getColumnCount()Read-only property that returns the number of columns in the GridControl.
public void setColumnViews(borland.jbcl.view.ColumnView[] newViews)A ColumnView object contains the attributes that describe a visible column in the GridControl. columnViews is an array of ColumnView objects.
Overrides: borland.jbcl.view.GridView.columnViews
public DataSet getDataSet() public void setDataSet(borland.jbcl.dataset.DataSet newDataSet)The DataSet that provides the data displayed in the GridControl. Editing the data in the grid and then posting the changes makes changes to the data in the data set. When a data set is specified for the dataSet property, the GridControl is being used as a data-aware control.
public synchronized String[][] getItems() public synchronized void setItems(java.lang.String[][] newItems)Set this property to make the grid control behave like a string grid. When the items property is specified, the grid is not being used as a data-aware control.
The property editor for the items property in the Component Inspector displays the following dialog:
public void setModel(borland.jbcl.model.MatrixModel model)The object that actually contains the data. This property is used by the items property.
public boolean isMultiSelect() public void setMultiSelect(boolean select)Allows or prevents user-selection of a range of cells. Overrides selectRow and selectColumn.
public boolean isNavigateWithDataSet() public void setNavigateWithDataSet(boolean navigate)Set this property to control whether the GridControl's sub-focus drives the dataSet and vice-versa. If true, navigating within the Grid navigates all controls connected to the same dataSet. If false, the Grid will navigate independently of other controls connected to the dataSet.
public int getRowCount()Reports the number of rows of data displayed in the grid.
public boolean isSelectColumn() public void setSelectColumn(boolean select)When selectColumn is true, clicking a cell in the grid selects the entire column the cell is located in.
public boolean isSelectRow() public void setSelectRow(boolean select)When selectRow is true, clicking a cell in the grid selects the entire row the cell is located in.
public boolean isShowPopup() public void setShowPopup(boolean show)
Whether to show the context menu when the pointer is over the grid cells and the user right-clicks. This is an example of a right-click menu:
public boolean isSortOnHeaderClick() public void setSortOnHeaderClick(boolean sort)If sortOnHeaderClick is true and dataSet is set, clicking on the header of a column sorts that column. If it is false or if dataSet is not set, clicking on the header of a column moves the focus to that column.
public String getTextureName() public void setTextureName(java.lang.String path)Determines the name of the Image file that is tiled on the background of the control to give the appearance of texture. Specify the file name and directory using the path parameter.
public boolean isVariableColumns()The variableColumns property determines whether columns can be added to or removed from the matrix model that supplies the GridControl. If variableColumns is true, columns can be added or removed.
public boolean isVariableRows()The variableRows property determines whether rows can be added to or removed from the matrix model that supplies the GridControl. If variableRows is true, rows can be added or removed.
public void addNotify()A hook to open the dataSet when the Grid is displayed, if the dataSet's autoOpen property is set.
protected void buildColumnViews(borland.jbcl.dataset.DataSet cursor)
protected void columnHeaderClicked(int column)An event response method that checks on the sort state of the grid and acts accordingly.
public void toggleColumnSort(int column)Calls DataSet.toggleViewOrder() for the current column. The method is called only if a DataSet is used. If the DataSet is in the editing state, toggleColumnSort() posts the data to the data set before sorting the data in the grid.
public void addActionListener(java.awt.event.ActionListener l) public void removeActionListener(java.awt.event.ActionListener l)
public void addAncestorListener(com.sun.java.swing.event.AncestorListener ) public void removeAncestorListener(com.sun.java.swing.event.AncestorListener )
public synchronized void addComponentListener(java.awt.event.ComponentListener ) public synchronized void removeComponentListener(java.awt.event.ComponentListener )
public synchronized void addContainerListener(java.awt.event.ContainerListener ) public void removeContainerListener(java.awt.event.ContainerListener )
public void addCustomItemListener(borland.jbcl.view.CustomItemListener l) public void removeCustomItemListener(borland.jbcl.view.CustomItemListener l)
public void addFocusListener(java.awt.event.FocusListener listener) public void removeFocusListener(java.awt.event.FocusListener listener)
public void addHeaderListener(borland.jbcl.view.HeaderListener l) public void removeHeaderListener(borland.jbcl.view.HeaderListener l)
public void addKeyListener(java.awt.event.KeyListener l) public void removeKeyListener(java.awt.event.KeyListener l)
public void addModelListener(borland.jbcl.model.MatrixModelListener listener) public void removeModelListener(borland.jbcl.model.MatrixModelListener listener)
public void addMouseListener(java.awt.event.MouseListener l) public void removeMouseListener(java.awt.event.MouseListener l)
public void addMouseMotionListener(java.awt.event.MouseMotionListener l) public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener ) public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )
public void addSelectionListener(borland.jbcl.model.MatrixSelectionListener listener) public void removeSelectionListener(borland.jbcl.model.MatrixSelectionListener listener)
public void addSubfocusListener(borland.jbcl.model.MatrixSubfocusListener listener) public void removeSubfocusListener(borland.jbcl.model.MatrixSubfocusListener listener)
public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener ) public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )