borland.jbcl Packages  borland.jbcl Class Hierarchy  borland.jbcl.view 

GridView component

java.lang.Object
   +----java.awt.Component
           +----java.awt.Container
                   +----java.awt.Panel
                           +----borland.jbcl.view.GridView
                                   +----borland.jbcl.control.GridControl

About the GridView component

Variables  Constructors  Properties  Methods  Event Listeners

Implements HeaderListener, MatrixView, Scroller, MenuContainer, ImageObserver, Serializable, EventListener

GridView is a scrollable view of matrix data with a row header and a column header. It uses a Panel that contains:

It also uses a ColumnView.

This class delegates all the necessary methods to other classes, which are:


GridView variables

Variables implemented in this class

Variables implemented in java.awt.Component

GridView constructors

GridView properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.awt.Component

Properties implemented in java.awt.Container

Properties implemented in java.lang.Object

GridView methods

Methods implemented in this class

Methods implemented in java.awt.Component

Methods implemented in java.awt.Container

Methods implemented in java.lang.Object

GridView event listeners


GridView variables

bInsets

  protected Insets bInsets

border

  protected BorderItemPainter border

button

  protected ButtonView button

columnHeader

  protected HeaderView columnHeader

columnHeaderHeight

  protected int columnHeaderHeight

columnHeaderVisible

  protected boolean columnHeaderVisible

hScroll

  protected Scrollbar hScroll

hScrollHeight

  protected int hScrollHeight

panel

  protected Panel panel

prefSize

  protected Dimension prefSize

rowHeader

  protected HeaderView rowHeader

rowHeaderVisible

  protected boolean rowHeaderVisible

rowHeaderWidth

  protected int rowHeaderWidth

showHScroll

  protected boolean showHScroll

showVScroll

  protected boolean showVScroll

vScroll

  protected Scrollbar vScroll

vScrollWidth

  protected int vScrollWidth

GridView constructors

GridView()

  public GridView()
Constructs a grid view.


GridView properties

alwaysEdit

 public boolean isAlwaysEdit()
 public void setAlwaysEdit(boolean alwaysEdit)
The alwaysEdit property controls whether or not the grid will automatically start an edit session when subfocus moves to a new cell. By default, this is false, and a user must type a key, double-click, or press F2 to edit a cell's value. If true, moving subfocus will always start an edit session of the cell.

autoEdit

 public boolean isAutoEdit()
 public void setAutoEdit(boolean autoEdit)
The autoEdit property enables or disables automatic cell editing in the grid. By default, this property is true, and a user can edit values in any cell on the grid by typing a character on the keyboard. If set to false, the user must press F2 or Ctrl+Enter, or double-click to start an edit session. By default, this property is true.

batchMode

 public boolean isBatchMode()
 public void setBatchMode(boolean batchMode)
The batchMode property enables or disables all painting in the grid. This is used for programmatic mass updates to the grid's model, selection, or related elements, without triggering repaint() messages.

columnHeaderHeight

 public int getColumnHeaderHeight()
 public void setColumnHeaderHeight(int height)
The columnHeaderHeight property defines the height of the column header in pixels.

columnHeaderVisible

 public boolean isColumnHeaderVisible()
 public void setColumnHeaderVisible(boolean visible)
The columnHeaderVisible property controls wether or not the column header is visible. The default is true.

columnSizes

 public SizeVector getColumnSizes()
 public void setColumnSizes(borland.jbcl.view.SizeVector newSizes)
The columnSizes property defines a SizeVector to manage the column widths in the grid. SizeVector is an interface that has two common implementations: FixedSizeVector, and VariableSizeVector. FixedSizeVector keeps all the column widths identical. A VariableSizeVector (the default for columnSizes) allows a different size for each column.

columnViews

 public ColumnView[] getColumnViews()
 public void setColumnViews(borland.jbcl.view.ColumnView[] columnViews)
A ColumnView defines the view state information for a particular column in the grid. The ColumnView class defines properties such as background, foreground, and font. Every column displayed in the grid has a ColumnView to go with it. Individual ColumnViews can be set using this indexed columnView property. The entire set of ColumnViews can be set using the columnViews property.

coreComponent

 public Component getCoreComponent()
Returns the contained GridCore (non-public) class instance as a Component.

defaultColumnWidth

 public int getDefaultColumnWidth()
 public void setDefaultColumnWidth(int defaultWidth)
The defaultColumnWidth property is the columnWidth used when a new column is inserted into the grid. The default is 100 pixels.

doubleBuffer

 public boolean isDoubleBuffer()
 public void setDoubleBuffer(boolean doubleBuffer)
The doubleBuffer property enables or disables the double-buffered screen painting built into the grid. The default is true, and the grid paints all of the visible cells onto an off-screen image before blitting the image onto the screen (to prevent flicker). Setting doubleBuffer to false will disable this functionality, and all ItemPainters will paint directly to the screen. This property is set to false when a user is placing a grid onto a Panel (or other container) that has its own double-buffering, or if the user really likes things that flicker.

dragSubfocus

 public boolean isDragSubfocus()
 public void setDragSubfocus(boolean dragSubfocus)
The dragFocus property enables or disables dragging of the subfocus cell when dragging the mouse pointer over the grid (with the mouse button pressed). By default, this property is true.

editInPlace

 public boolean isEditInPlace()
 public void setEditInPlace(boolean editInPlace)
The editInPlace property enables or disables cell editing in the grid. By default, this property is true, and a user can edit values in any cell on the grid. If set to false, the matrix data cannot by modified by the user, except through programmatic access to the grid's model.

editing

 public boolean isEditing()
The editing property (read-only) returns true if a cell is currently being edited in the grid.

gridLineColor

 public Color getGridLineColor()
 public void setGridLineColor(java.awt.Color gridLineColor)
The gridLineColor property defines the line color for the grid. The default color for the grid lines is SystemColor.control.

gridVisible

 public boolean isGridVisible()
 public void setGridVisible(boolean visible)
The gridVisible property shows or hides the grid lines. The default is true.

increments

 public void setIncrements(java.awt.Point p)

minimumSize

 public Dimension getMinimumSize()

model

 public MatrixModel getModel()
 public void setModel(borland.jbcl.model.MatrixModel model)
The model property defines the MatrixModel that this grid is displaying data from. If the current model is an instance of WritableMatrixModel, an external user can get access to it using getWriteModel().

postOnEndEdit

 public boolean isPostOnEndEdit()
 public void setPostOnEndEdit(boolean post)
The postOnEndEdit property controls whether or not the grid will post changes to a cell back to the model when the user clicks off of the cell, or tabs off of the cell. If false, editing a cell's value will not "stick" unless committed by pressing Enter. Clicking off of the cell being edited will revert the value back to its original state. By default, this property is set to true.

preferredSize

 public Dimension getPreferredSize()
 public void setPreferredSize(java.awt.Dimension prefSize)

readOnly

 public boolean isReadOnly()
 public void setReadOnly(boolean ro)
The readOnly property is used when the model property is actually a WritableMatrixModel, but the user wants it to be treated as a read-only model. This is commonly used to allow users to browse, but not edit, normally writable matricies of data.

resizableColumns

 public boolean isResizableColumns()
 public void setResizableColumns(boolean resizable)
The resizableColumns property controls whether or not the grid columns are resizable by the user. The default is true, and the columns can be resized using the mouse.

resizableRows

 public boolean isResizableRows()
 public void setResizableRows(boolean resizable)
The resizableRows property controls whether or not the grid rows are resizable by the user. The default is true, and the rows can be resized using the mouse.

rowHeaderVisible

 public boolean isRowHeaderVisible()
 public void setRowHeaderVisible(boolean visible)
The rowHeaderVisible property controls whether or not the rowHeader is visible. The default is true.

rowHeaderWidth

 public int getRowHeaderWidth()
 public void setRowHeaderWidth(int width)
The rowHeaderWidth property defines the width of the row header in pixels.

rowSizes

 public SizeVector getRowSizes()
 public void setRowSizes(borland.jbcl.view.SizeVector newSizes)
The rowSizes property defines a SizeVector to manage the row heights in the grid. SizeVector is an interface that has two common implementations: FixedSizeVector, and VariableSizeVector. FixedSizeVector (which is the default for rowSizes) keeps all the row sizes identical. VariableSizeVector allows a different size for each row.

scrollPosition

 public Point getScrollPosition()

scrollUnits

 public int getScrollUnits()

selection

 public WritableMatrixSelection getSelection()
 public void setSelection(borland.jbcl.model.WritableMatrixSelection wms)
The selection property defines a WritableMatrixSelection manager. This allows multiple matrix viewers to share the same selection pool, and allows the grid to handle selection in a generic manner. This allows users to plug in their own implemention of a selection manager, to have custom selection behavior.

showFocus

 public boolean isShowFocus()
 public void setShowFocus(boolean visible)
The showFocus property enables or disables the painting of the focus rectangle on the current subfocus cell. In reality, the showFocus property turns on or off the FOCUSED bit in the state information that is passed to the ItemPainter when a cell is painted. If an ItemPainter plugged into the grid ignores the FOCUSED bit, this property will have no effect. By default, showFocus is true.

showHScroll

 public boolean isShowHScroll()
 public void setShowHScroll(boolean visible)
The showHScroll property displays or hides the horizontal scrollbar. Scrolling will still function normally with the keyboard if the scrollbar is invisible.

showVScroll

 public boolean isShowVScroll()
 public void setShowVScroll(boolean visible)
The showVScroll property displays or hides the vertical scrollbar. Scrolling will still function normally with the keyboard if the scrollbar is invisible.

subfocus

 public MatrixLocation getSubfocus()
 public void setSubfocus(borland.jbcl.model.MatrixLocation newSubfocus)
The subfocus property defines the "current" cell (defined by a MatrixLocation) in the grid. This is the cell that is receiving keyboard input. The subfocus can be set using a MatrixLocation, or by specifying a row and column pair.

viewManager

 public MatrixViewManager getViewManager()
 public void setViewManager(borland.jbcl.model.MatrixViewManager viewManager)
The viewManager property defines the MatrixViewManager that will broker ItemPainters and ItemEditors to this grid. If a ColumnView has a defined ItemPainter and/or ItemEditor for a particular column, those will be used. If not, which is typical, the ItemPainters and ItemViewers are obtained from this view manager. The view manager is esentially a back-stop for the grid.

viewportSize

 public Dimension getViewportSize()

writeModel

 public WritableMatrixModel getWriteModel()

GridView methods

addNotify()

  public void addNotify()
Overrides:
java.awt.Panel.addNotify()

columnHeaderClicked(int)

  protected void columnHeaderClicked(int index)

endEdit()

  public void endEdit()
Ends the current edit session (if any). If the value has been modified, it will be posted if postOnEndEdit is set to true (the default). If postOnEndEdit is false, the edit session will be terminated without saving the changes to the cell value.

endEdit(boolean)

  public void endEdit(boolean post)
Ends the current edit session (if any). If the value has been modified, it will be posted if post is set to true. If post is false, the edit session will be terminated without saving the changes to the cell value.

getCellRangeRect(borland.jbcl.model.MatrixLocation, borland.jbcl.model.MatrixLocation)

  public Rectangle getCellRangeRect(borland.jbcl.model.MatrixLocation start, borland.jbcl.model.MatrixLocation end)
Returns the Rectangle (in pixels) that bounds the range of cells at the specified locations. Coordinates are relative to the entire scrollable region inside of the GridView. Use getScrollPosition() and getViewportSize() to calculate relative point positions to external components.

Returns the bounding rectangle of the cell range.

Parameters:

start
The top-left cell location to calculate.
end
The bottom-right cell location to calculate.

getCellRect(borland.jbcl.model.MatrixLocation)

  public Rectangle getCellRect(borland.jbcl.model.MatrixLocation cell)
Returns the Rectangle (in pixels) that bounds the cell at the specified location. Coordinates are relative to the entire scrollable region inside of the GridView. Use getScrollPosition() and getViewportSize() to calculate relative point positions to external components.

Returns the bounding rectangle of the cell range.

Parameters:

cell
The cell that you want the rectangle for.

getColumnView(int)

  public ColumnView getColumnView(int index)

getColumnWidth(int)

  public int getColumnWidth(int row)

getRowHeight(int)

  public int getRowHeight(int row)

hitTest(int, int)

  public MatrixLocation hitTest(int x, int y)
Returns the address (MatrixLocation) of the cell at the coordinates specified. Coordinates are relative to the entire scrollable region inside of the GridView. Use getScrollPosition() and getViewportSize() to calculate relative point positions to external components.

Returns the MatrixLocation (row,column) that was hit, or null if nothing was hit.

Parameters:

x
The x location.
y
The y location.

paint(java.awt.Graphics)

  public void paint(java.awt.Graphics g)
Overrides:
java.awt.Container.paint(Graphics)

repaintCell(borland.jbcl.model.MatrixLocation)

  public void repaintCell(borland.jbcl.model.MatrixLocation cell)
Repaints the cell at the passed location.

repaintCells()

  public void repaintCells()
Repaints all the visible cells in the grid.

repaintCells(borland.jbcl.model.MatrixLocation, borland.jbcl.model.MatrixLocation)

  public void repaintCells(borland.jbcl.model.MatrixLocation start, borland.jbcl.model.MatrixLocation end)
Repaints all the visible cells in the range between the start and end cell location.

Parameters:

start
The top-left cell location to repaint.
end
The bottom-right cell location to repaint.

requestFocus()

  public void requestFocus()

Overrides: java.awt.Component.requestFocus()

reset()

  public void reset()
Resets the scroll position, sets the subfocus back to (0,0), and makes sure the grid is properly sized and validated.

resyncEditor()

  public void resyncEditor()
Moves any embedded editor to its proper position (and size) if the GridView has been externally manipulated. This method is used by subclasses or consumers that are manipulating the rowSizes and columnSizes while the grid is in an edit session.

rowHeaderClicked(int)

  protected void rowHeaderClicked(int index)

scrolled(boolean, int)

  public void scrolled(boolean vert, int value)

setColumnView(int, borland.jbcl.view.ColumnView)

  public void setColumnView(int index, borland.jbcl.view.ColumnView col)
A ColumnView defines the view state information for a particular column in the grid. The ColumnView class defines properties such as background, foreground, and font. Every column displayed in the grid has a ColumnView to go with it. Individual ColumnViews can be set using this indexed columnView property. The entire set of ColumnViews can be set using the columnViews property.

setColumnWidth(int, int)

  public void setColumnWidth(int column, int width)
Individual column widths can be modified using the columnWidth indexed property. Column widths are controlled by a SizeVector, which, by default, is a VariableSizeVector. If you want the columns to all match widths, see the columnSizes property to plug in a FixedSizeVector.

setRowHeight(int, int)

  public void setRowHeight(int row, int height)
Individual row heights can be modified using the rowHeight indexed property. Row heights are controlled by a SizeVector, which, by default, is a FixedSizeVector. A FixedSizeVector will set all of the row heights to the setting that is passed, regardless of the row index passed. If you want to modify individual row heights, use the rowSizes property, to plug in a VariableSizeVector.

setSubfocus(int, int)

  public void setSubfocus(int row, int column)

startEdit(borland.jbcl.model.MatrixLocation)

  public void startEdit(borland.jbcl.model.MatrixLocation cell)
Starts an edit session at the cell location defined by cell. If editInPlace is false or if readOnly is true, this method is a no-op.

update(java.awt.Graphics)

  public void update(java.awt.Graphics g)

Overrides: java.awt.Component.update(java.awt.Graphics)


GridView event listeners

This component is a source for the following event sets. For information on the standard AWT event sets, see Standard Java events. For information on the JBCL event sets, see Events in JBCL.

action

 public void addActionListener(java.awt.event.ActionListener l)
 public void removeActionListener(java.awt.event.ActionListener l)

component

 public synchronized void addComponentListener(java.awt.event.ComponentListener l)
 public synchronized void removeComponentListener(java.awt.event.ComponentListener l)

container

 public synchronized void addContainerListener(java.awt.event.ContainerListener l)
 public void removeContainerListener(java.awt.event.ContainerListener l)

focus

 public void addFocusListener(java.awt.event.FocusListener listener)
 public void removeFocusListener(java.awt.event.FocusListener listener)

key

 public void addKeyListener(java.awt.event.KeyListener l)
 public void removeKeyListener(java.awt.event.KeyListener l)

model

 public void addModelListener(borland.jbcl.model.MatrixModelListener listener)
 public void removeModelListener(borland.jbcl.model.MatrixModelListener listener)

mouse

 public void addMouseListener(java.awt.event.MouseListener l)
 public void removeMouseListener(java.awt.event.MouseListener l)

mouseMotion

 public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
 public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)

selection

 public void addSelectionListener(borland.jbcl.model.MatrixSelectionListener listener)
 public void removeSelectionListener(borland.jbcl.model.MatrixSelectionListener listener)

subfocus

 public void addSubfocusListener(borland.jbcl.model.MatrixSubfocusListener listener)
 public void removeSubfocusListener(borland.jbcl.model.MatrixSubfocusListener listener)