|
Diamond Control Suite 3.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JTable diamondedge.swing.grid.DsTable diamondedge.swing.grid.DsGrid
public class DsGrid
DsGrid is a data-aware drop-in replacement for JTable
which is used to display and
edit regular two-dimensional tables of cells. It provides full and easy formatting and styles
for each cell, column, or row. For binding to databases, the ResultSetModel provides a
scalable and high performance virtual view of up to 2 billion records from a JDBC ResultSet.
The data in the grid can be formatted, sorted, printed and edited using any of the models supplied
or any user defined TableModel.
A very easy and flexible object model is available to format and modify the style of cells in the grid. Cells can be individually changed such as:
grid.getCellAt( 1, 2 ).setForeground( Color.blue );
The selected cells can be easily changed such as:
grid.getCells().setBackground( Color.yellow );
All cells in certain columns can be changed easily:
grid.getColumns( 1, 2 ).setHorizontalAlignment( DsConstants.CENTER );
All cells in certain rows can be changed easily:
grid.getRows( 1, 2 ).setFontBold( true );
Cells can be formatted using Java's Format objects such as formatting the 2nd and 3rd column
to display as a currency using the default locales currency format:
grid.getColumns( 1, 2 ).setFormat( NumberFormat.getCurrencyInstance() );
Cells can contain calculated values by setting a formula for the cell:
grid.setFormulaAt( "sum(A1:C1)", 0, 3 );
See Formula Functions Reference
for a list of the functions available within formulas.
Note that DsTable provides many additional features such as spanning while JTable provides the base implementation.
See Diamond Grid Tutorial (or on the
web site)
for task-oriented documentation and more examples of using features specific to DsGrid
.
See How to Use Tables
in The Java Tutorial
for task-oriented documentation and examples of using JTable
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class diamondedge.swing.grid.DsTable |
---|
DsTable.BooleanEditor, DsTable.BooleanRenderer, DsTable.ComponentEditor, DsTable.ComponentRenderer, DsTable.DateEditor, DsTable.ListEditor, DsTable.TableEditor |
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
ALTERNATING_ROW_COLOR
|
static int |
AUTO_LABEL_NONE
|
static int |
AUTO_LABEL_START_WITH_0
|
static int |
AUTO_LABEL_START_WITH_1
|
static int |
AUTO_LABEL_START_WITH_A
|
protected Paint |
autoColor1
|
protected Paint |
autoColor2
|
protected Paint |
autoColor3
|
protected Paint |
autoColor4
|
protected boolean |
leaveFrozenColumns
if set to true then the columns remain in the column model when they are frozen and a copy is placed in the row header. |
static int |
SELECTION_BY_COLUMN
Selections to span entire columns, as if selecting ranges for a chart or fields for sorting. |
static int |
SELECTION_BY_ROW
Selections to span entire rows, as in a multi-column list box or record-based display. |
static int |
SELECTION_FREE
Individual cells to be selected, spreadsheet style. |
static String |
version
|
Fields inherited from class diamondedge.swing.grid.DsTable |
---|
cellsEditable, spannedCells |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface diamondedge.swing.DsConstants |
---|
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
DsGrid()
|
|
DsGrid(int rows,
int cols)
|
|
DsGrid(TableModel dataModel)
|
Method Summary | |
---|---|
void |
addColumnClickListener(ColumnClickListener listener)
Add a listener to the list that's notified each time a column is clicked on. |
void |
addGridEditorListener(GridEditorListener l)
Adds a listener to the list that's notified each time the editing state has changed. |
void |
addRow()
Append a new row. |
void |
addRow(Object item)
Append a new row with item being value in the first column. |
void |
addTableModelListener(TableModelListener l)
|
void |
addTabOrder(DsCellRange cells)
|
void |
addTabOrder(int row,
int col)
|
void |
addTabOrder(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
|
protected void |
applyAutoStyle()
|
void |
changeSelection(int row,
int column,
boolean toggle,
boolean extend)
Overriden to not allow mouse to select cells that are not in tab order |
void |
clear()
Clears the contents of each cell. |
void |
clearTabOrder()
|
protected void |
configureEnclosingScrollPane()
|
protected void |
configureRowHeader()
|
void |
copyToClipboard()
|
void |
copyToClipboard(boolean all,
boolean includeColHeaders)
|
void |
editingCanceled(ChangeEvent e)
Invoked when editing is canceled. |
void |
editingStopped(ChangeEvent e)
Invoked when editing is finished. |
void |
ensureVisible(int row)
Scroll to make sure the row is visible on the screen |
void |
ensureVisible(int row,
int column)
Scroll to make sure the cell is visible on the screen |
DsCellRange |
find(Object searchFor,
int matchType,
int action)
Finds a value in a cell or multiple cells. |
protected void |
fireColumnClicked(MouseEvent e)
This method notifies the ColumnClickListeners that a column has been clicked on. |
protected boolean |
fireGridEditorEvent(int eventType,
int row,
int col,
Component editor)
|
void |
focusGained(FocusEvent e)
|
void |
focusLost(FocusEvent e)
|
void |
freezeColumn(int col)
Turns the specified column into a fixed (non-scrollable) column by moving the columns into the RowHeader. |
Image |
getBackgroundImage()
Return the image that is painted on the background surface |
DsCell |
getCell()
Returns the active cell. |
DsCellRange |
getCells()
Returns a range of cells defined by the user's selection or by the combination of the Row, Col, Row2, Col2 properties. |
DsCellRange |
getCells(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
Returns a range of cells in between and including the specified cell corners. |
Object |
getCellValue()
Returns the text contents/object for the active cell. |
String |
getClipString()
Returns the selected cells formated into a tab delimited string. |
int |
getCol()
Returns the column of the active cell. |
int |
getCol2()
Determines the starting or ending column for a range of cells. |
int |
getColumnAtPoint(Point point)
Returns the index of the column that point lies in or -1 if not a valid column. |
Class |
getColumnClass(int column)
Returns the type of the column appearing in the view at column position column . |
protected JViewport |
getColumnHeaderViewport()
|
DsCellRange |
getColumns(int firstColumn,
int lastColumn)
Returns a range of cells that includes all cells in the specified columns. |
int |
getFirstVisibleColumn()
Returns the index of the column that is displayed at the left of the grid |
int |
getFirstVisibleRow()
Returns the index of the row that is displayed at the top of the grid |
int |
getFrozenColumnCount()
Returns the total number of fixed (non-scrollable) columns. |
GridModel |
getGridModel()
Returns the inner most TableModel which is an instance of GridModel. |
int |
getHighlightPolicy()
Determines when the selection is highlighted. |
int |
getNumClicksToSort()
Returns the number of clicks on the column header required to allow the user to select the column to sort on or to change the sort order. |
int |
getRow()
Returns the row of the active cell. |
int |
getRow2()
Determines the starting or ending row for a range of cells. |
int |
getRowAtPoint(Point point)
Returns the index of the row that point lies in or -1 if not a valid row. |
GridRowHeader |
getRowHeader()
Returns fixed columns displaying a row header for each row. |
int |
getRowHeaderAutoLabel()
Returns a value that determines the automatic assignment of the row header values. |
protected JViewport |
getRowHeaderViewport()
|
int |
getRowHeaderWidth()
Returns a value that determines the automatic assignment of the row header values. |
DsCellProperties |
getRowProperties(int row)
Returns the default cell containing the default properties for the row. |
DsCellRange |
getRows(int firstRow,
int lastRow)
Returns a range of cells that includes all cells in the specified rows. |
int |
getSortColumn()
Returns the column in the model that is currently being used to sort the rows. |
int |
getSortOrder()
Returns whether or not the rows will be sorted in ascending or descending order. |
String |
getTextAt(int row,
int col)
Returns the text (contents formatted as a string) for the cell at the given row and column. |
int |
getTopVisibleRow()
Deprecated. replaced by getFirstVisibleRow() |
void |
insertRow(int index,
String item)
Adds a new row at run time at the given position. |
boolean |
isAutoRecalc()
Returns whether recalcFormulas() automatically called when cell values change. |
boolean |
isCellEditable(int row,
int column)
Returns true if the cell at row and column is editable. |
boolean |
isColumnHeaderVisible()
Returns whether there is a fixed row displaying a column header for each column. |
boolean |
isRowHeaderVisible()
Returns whether there are fixed columns displaying a row header for each row. |
boolean |
isRowStatusIconShowing()
Returns whether an icon will be shown in the row header indicating the status of the row. |
boolean |
isSorted()
Indicates whether the rows are automatically sorted alphabetically. |
void |
loadCSV(File file,
boolean firstRowIsColHeader)
Load data from a text stream formatted as comma separated values. |
void |
loadCSV(Reader reader,
boolean firstRowIsColHeader,
boolean convertData)
Load data from a text stream formatted as comma separated values. |
void |
loadResultSet(ResultSet rs,
boolean setHeaderColumns)
Loads data from the ResultSet into the grid. |
void |
loadResultSet(ResultSet rs,
int begRow,
int begCol,
int endRow,
int endCol)
Loads data from the ResultSet into the grid. |
void |
loadTabDelim(File file,
boolean firstRowIsColHeader)
Load data from a text stream formatted as tab delimited values. |
void |
loadTabDelim(Reader reader,
boolean firstRowIsColHeader,
boolean convertData)
Load data from a text stream formatted as tab delimited values. |
void |
loadTextData(Reader reader,
int begRow,
int begCol,
int endRow,
int endCol,
boolean firstRowIsColHeader,
char delim,
boolean stripStringDelim,
boolean convertData)
Load data from a text stream. |
static void |
main(String[] args)
|
void |
mouseClicked(MouseEvent e)
|
void |
mouseEntered(MouseEvent e)
|
void |
mouseExited(MouseEvent e)
|
void |
mousePressed(MouseEvent e)
|
void |
mouseReleased(MouseEvent e)
|
void |
paint(Graphics g)
|
void |
paste()
|
Component |
prepareEditor(TableCellEditor editor,
int row,
int column)
Creates and prepares the editor when an edit is requested. |
boolean |
print()
Print data using default properties |
boolean |
print(boolean showPrintDialog,
double scaleFactor,
DsCellRange range,
String footer,
int showColumnHeader,
int showRowHeader)
Print data in the grid. |
void |
printPreview()
Preview the data in the grid as it would appear on the printed page. |
void |
printPreview(boolean showAllPages,
double scaleFactor,
DsCellRange range,
String footer,
int showColumnHeader,
int showRowHeader)
Preview the data in the grid as it would appear on the printed page. |
void |
recalcFormulas()
Calculate the values of all of the formulas. |
void |
removeAll()
Removes all cells including all rows and columns. |
void |
removeColumnClickListener(ColumnClickListener listener)
Remove a listener from the list that's notified each time a column is clicked on. |
void |
removeGridEditorListener(GridEditorListener l)
Removes a listener from the list that's notified each time the editing state has changed. |
void |
removeRow(int index)
Removes a row at run time |
void |
removeTableModelListener(TableModelListener l)
|
DsCellRange |
replace(Object searchFor,
int matchType,
Object replaceWith)
Finds values in a cell or multiple cells and replaces the entire value with the value specified. |
void |
rowChanged(GridEvent e)
|
void |
saveAsCSV(File file,
boolean saveHeaderColumns)
Save data to a file with comma separated value format. |
void |
saveAsHTML(File file,
boolean saveHeaderColumns)
Save data to a HTML formated stream. |
void |
saveAsHTML(Writer writer,
int begRow,
int begCol,
int endRow,
int endCol,
boolean saveHeaderColumns)
Save data to a HTML formated stream. |
void |
saveAsTabDelim(File file,
boolean saveHeaderColumns)
Save data to a file with tab delimeted text format. |
void |
saveAsTextData(Writer writer,
int begRow,
int begCol,
int endRow,
int endCol,
boolean saveHeaderColumns,
char delim,
boolean addStringDelim)
Save data to a delimeted stream such as tab-delimeted or csv. |
boolean |
select(int row,
int col)
Sets the row and column of the active cell. |
boolean |
select(int row,
int col,
int row2,
int col2)
Sets the row and column of the active cell which is the beginning of the selection. |
void |
setAutoRecalc(boolean automaticallyRecalculateFormulas)
Sets whether recalcFormulas() automatically called when cell values change. |
void |
setAutoResizeMode(int autoResize)
Sets the table's auto resize mode when the table is resized. |
void |
setAutoStyle(int autoStyle)
Automatically sets the styles for rows and columns using default colors. |
void |
setAutoStyle(int autoStyle,
Paint color1,
Paint color2,
Paint color3,
Paint color4)
Automatically sets the styles for rows and columns. |
void |
setBackgroundImage(Image image)
Set the image that is painted on the background surface. |
void |
setBackgroundImageStyle(int style)
Paint the background image using the given style |
void |
setCellValue(Object value)
Sets the text contents/object for the active cell. |
void |
setClipString(String tabDelimtedStr)
Replaces the selected cells with the values from the tab delimited string. |
void |
setCol(int col)
Sets the column of the active cell. |
void |
setCol2(int val)
Determines the starting or ending column for the selected range of cells. |
void |
setColumnClass(int column,
Class type)
Sets the type of the column appearing in the view at column position column . |
void |
setColumnHeaderVisible(boolean visible)
Sets whether there is a fixed row displaying a column header for each column. |
void |
setColumnSelectionAllowed(boolean columnSelectionAllowed)
Sets whether the columns in this model can be selected. |
void |
setFormulaAt(String formula,
int row,
int col)
Sets the formula for the cell at the given row and column. |
void |
setFrozenColumnCount(int val)
Sets the total number of fixed (non-scrollable) columns by moving the specified number of columns into the RowHeader. |
void |
setHighlightPolicy(int val)
Determines when the selection is highlighted. |
void |
setModel(TableModel dataModel)
|
void |
setNumClicksToSort(int numClicks)
Allow the user to interactively select which column to sort on by clicking on the column header. |
void |
setRow(int row)
Sets the row of the active cell. |
void |
setRow2(int row)
Determines the starting or ending row for a range of cells. |
void |
setRowCount(int val)
Sets the total number of rows by adding new blank rows or removing rows. |
void |
setRowHeaderAutoLabel(int autoLabel)
Set the automatic assignment of the row header values. |
void |
setRowHeaderVisible(boolean visible)
Sets whether there are fixed columns displaying a row header for each row. |
void |
setRowHeaderWidth(int width)
Set the total width of all columns in the row header. |
void |
setRowHeaderWidthToFit(boolean fitColumnNames,
boolean fitColumnData,
int columnMargin)
Sets the total width of the row header needed to fit the text for the name of the column and/or the data in cells in that column for each column in the row header. |
void |
setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to rowHeight ,
revalidates, and repaints. |
void |
setRowHeight(int row,
int rowHeight)
Sets the height for row to rowHeight ,
revalidates, and repaints. |
void |
setRowSelectionAllowed(boolean rowSelectionAllowed)
Sets whether the columns in this model can be selected. |
void |
setRowStatusIconShowing(boolean showRowIcon)
Determines whether an icon will be shown in the row header indicating the status of the row. |
void |
setSelectionPolicy(int val)
Sets whether it should allow regular cell selection, selection by rows, or selection by columns. |
void |
setSortColumn(int modelIndex)
Sets the column index in the model that is to be used to sort the rows. |
void |
setSorted(boolean sort)
Sets whether the rows are automatically sorted alphabetically. |
void |
setSortIcons(Icon ascendingSortIcon,
Icon descendingSortIcon)
Set custom icons that show which direction a column is sorted These are only used if sorting by one column |
void |
setSortOrder(int sortOrder)
Sets whether or not the rows will be sorted in ascending or descending order. |
void |
setValueAt(Object val,
int row,
int col)
Sets the text contents/object for the cell at the given row and column. |
void |
sort()
Sorts the list items according to the current sort column and order. |
void |
sort(int column,
int sortOrder)
Sorts the model by comparing values in the given column. |
boolean |
spanCells(int startRow,
int startColumn,
int rowsToSpan,
int columnsToSpan)
Makes the cell at position startRow, startColumn span
across rowsToSpan rows and columnsToSpan columns. |
void |
tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates
a TableModelEvent . |
void |
updateUI()
|
void |
valueChanged(ListSelectionEvent e)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.swing.table.TableModel |
---|
getColumnCount, getColumnName, getRowCount, getValueAt |
Field Detail |
---|
public static String version
public static final int SELECTION_FREE
public static final int SELECTION_BY_ROW
public static final int SELECTION_BY_COLUMN
public static final int AUTO_LABEL_NONE
public static final int AUTO_LABEL_START_WITH_0
public static final int AUTO_LABEL_START_WITH_1
public static final int AUTO_LABEL_START_WITH_A
public static final int ALTERNATING_ROW_COLOR
protected Paint autoColor1
protected Paint autoColor2
protected Paint autoColor3
protected Paint autoColor4
protected boolean leaveFrozenColumns
Constructor Detail |
---|
public DsGrid()
public DsGrid(int rows, int cols)
public DsGrid(TableModel dataModel)
Method Detail |
---|
public void updateUI()
updateUI
in class DsTable
public final Image getBackgroundImage()
public void setBackgroundImage(Image image)
DsCellProperties.setOpaque(boolean)
,
DsCellProperties.setBackground(java.awt.Paint)
public void setBackgroundImageStyle(int style)
style
- One of: LEFT, CENTER, STRETCH, TILEpublic void paint(Graphics g)
paint
in class JComponent
public GridModel getGridModel()
public void setModel(TableModel dataModel)
setModel
in class JTable
public boolean isCellEditable(int row, int column)
isCellEditable
in interface TableModel
isCellEditable
in class DsTable
DsTable.setEditable(boolean)
public void setValueAt(Object val, int row, int col)
setValueAt
in interface TableModel
setValueAt
in class JTable
public void setFormulaAt(String formula, int row, int col)
See Formula Functions Reference for a list of the functions available within formulas..
public void setRowCount(int val)
public void setAutoStyle(int autoStyle)
setAutoStyle(int,Paint,Paint,Paint,Paint)
public void setAutoStyle(int autoStyle, Paint color1, Paint color2, Paint color3, Paint color4)
NONE
- don't set any styles automatically
ALTERNATING_ROW_COLOR
- sets the foreground and background colors of
alternating rows. The background color for the first row is color2
(white)
and the next row is color4
(lightGray) and then it uses color2
for the next row and so on alternating between the two colors.
The foreground colors are also set using color1
(black) and color3
(black)
protected void applyAutoStyle()
public void setAutoResizeMode(int autoResize)
setAutoResizeMode
in class JTable
JTable.setAutoResizeMode(int)
protected void configureEnclosingScrollPane()
configureEnclosingScrollPane
in class JTable
protected void configureRowHeader()
public final GridRowHeader getRowHeader()
setRowHeaderVisible(boolean)
protected final JViewport getRowHeaderViewport()
public final boolean isRowHeaderVisible()
public void setRowHeaderVisible(boolean visible)
public int getRowHeaderWidth()
public void setRowHeaderWidth(int width)
public void setRowHeaderWidthToFit(boolean fitColumnNames, boolean fitColumnData, int columnMargin)
DsTable.calculateWidthToFit(boolean, boolean)
,
setRowHeaderWidth(int)
public final int getRowHeaderAutoLabel()
public void setRowHeaderAutoLabel(int autoLabel)
AUTO_LABEL_NONE
- don't add any values to the row headers
AUTO_LABEL_START_WITH_0
- set each row header with a number starting with 0 and increasing 1 for each row
AUTO_LABEL_START_WITH_1
- (default) set each row header with a number starting with 1 and increasing 1 for each row
AUTO_LABEL_START_WITH_A
- set each row header with a string starting with A. (A...Z then AA...AZ, etc)
protected final JViewport getColumnHeaderViewport()
public final boolean isColumnHeaderVisible()
public void setColumnHeaderVisible(boolean visible)
public void freezeColumn(int col)
public final int getFrozenColumnCount()
public void setFrozenColumnCount(int val)
getRowHeader()
public final int getHighlightPolicy()
public void setHighlightPolicy(int val)
DsGrid.HIGHLIGHT_SELECTION_NEVER
DsGrid.HIGHLIGHT_SELECTION_ALWAYS
(default)
DsGrid.HIGHLIGHT_SELECTION_WITH_FOCUS
public void setSelectionPolicy(int val)
DsGrid.SELECTION_FREE
(default) This allows individual cells to be selected, spreadsheet style.
DsGrid.SELECTION_BY_ROW
This forces selections to span entire rows, as in a multi-column list box or record-based display.
DsGrid.SELECTION_BY_COLUMN
This forces selections to span entire columns, as if selecting ranges for a chart or fields for sorting.
public void setRowSelectionAllowed(boolean rowSelectionAllowed)
setRowSelectionAllowed
in class JTable
JTable.setRowSelectionAllowed(boolean)
public void setColumnSelectionAllowed(boolean columnSelectionAllowed)
setColumnSelectionAllowed
in class JTable
JTable.setColumnSelectionAllowed(boolean)
public final boolean isRowStatusIconShowing()
public void setRowStatusIconShowing(boolean showRowIcon)
public int getRow2()
public void setRow2(int row)
setRow(int)
public int getCol2()
public void setCol2(int val)
setCol(int)
public int getRow()
public void setRow(int row)
setRow2(int)
public boolean select(int row, int col)
setRow(int)
,
setCol(int)
,
setRow2(int)
,
setCol2(int)
public boolean select(int row, int col, int row2, int col2)
setRow(int)
,
setCol(int)
,
setRow2(int)
,
setCol2(int)
public final int getCol()
public void setCol(int col)
setCol2(int)
public int getRowAtPoint(Point point)
point
lies in or -1 if not a valid row.
JTable.rowAtPoint(java.awt.Point)
public int getColumnAtPoint(Point point)
point
lies in or -1 if not a valid column.
JTable.columnAtPoint(java.awt.Point)
public String getTextAt(int row, int col)
public final DsCell getCell()
getCellAt( getRow(), getCol() )
getRow()
,
getCol()
,
DsTable.getCellAt(int, int)
public final Object getCellValue()
getRow()
,
getCol()
,
DsTable.getCellValueAt(int, int)
public void setCellValue(Object value)
getRow()
,
getCol()
,
setValueAt(java.lang.Object, int, int)
public DsCellRange getCells()
Note: if the selection includes frozen and non-frozen columns then only the non-frozen columns are returned.
getRow()
,
getCol()
,
getRow2()
,
getCol2()
public DsCellRange getCells(int firstRow, int firstColumn, int lastRow, int lastColumn)
getCells
in class DsTable
firstRow
- the first row in the range of cellsfirstColumn
- the first column in the range of cellslastRow
- the last row in the range of cellslastColumn
- the last column in the range of cellspublic DsCellRange getRows(int firstRow, int lastRow)
getRows
in class DsTable
firstRow
- the first row in the range of cellslastRow
- the last row in the range of cells (inclusive)public DsCellRange getColumns(int firstColumn, int lastColumn)
getColumns
in class DsTable
firstColumn
- the first column in the range of cellslastColumn
- the last column in the range of cells (inclusive)public void clearTabOrder()
public void addTabOrder(int row, int col)
public void addTabOrder(DsCellRange cells)
public void addTabOrder(int firstRow, int firstColumn, int lastRow, int lastColumn)
public void changeSelection(int row, int column, boolean toggle, boolean extend)
changeSelection
in class JTable
public DsCellRange find(Object searchFor, int matchType, int action)
searchFor
- Object to find.matchType
- One of: FIND_STRING
- case insensitive search of a string that is equal to the toString() of the cell value
FIND_PREFIX
- case insensitive search of a string that matches the first part of the cell value's toString()
FIND_REGEX
- cell value whose toString() matches the given regular expression
FIND_EQUALS
- cell value that is equal to the given value. For strings this is case sensitive.
FIND_NE
- cell value that is not equal to the given value. For strings this is case sensitive.
FIND_GTE
- cell value that is greater than or equal to the given value
FIND_LTE
- cell value that is less than or equal to the given value
FIND_GT
- cell value that is greater than the given value
FIND_LT
- cell value that is less than the given value
FIND_ALL
- Search all cells. Otherwise search is stopped on the first match. Should be OR'ed in with one of the above values
action
- One of: SELECT_NONE, SELECT_CELL, SELECT_ROW
public DsCellRange replace(Object searchFor, int matchType, Object replaceWith)
searchFor
- Object to find.matchType
- One of: FIND_STRING
- case insensitive search of a string that is equal to the toString() of the cell value
FIND_PREFIX
- case insensitive search of a string that matches the first part of the cell value's toString()
FIND_REGEX
- cell value whose toString() matches the given regular expression
FIND_EQUALS
- cell value that is equal to the given value. For strings this is case sensitive.
FIND_NE
- cell value that is not equal to the given value. For strings this is case sensitive.
FIND_GTE
- cell value that is greater than or equal to the given value
FIND_LTE
- cell value that is less than or equal to the given value
FIND_GT
- cell value that is greater than the given value
FIND_LT
- cell value that is less than the given value
FIND_ALL
- Search all cells. Otherwise search is stopped on the first match. Should be OR'ed in with one of the above values
replaceWith
- the new value for each cell that is found
public Class getColumnClass(int column)
column
.
getColumnClass
in interface TableModel
getColumnClass
in class JTable
column
- the column in the view being queried
column
in the view where the first column is column 0public void setColumnClass(int column, Class type)
column
. This can be overriden by
the TableModel.getColumnClass method. By default the values in the cells can
have any type of value. If all columns need to be coerced to a
type then that type can be specified in this method. The type
being given must have a constructor that accepts a String argument.
column
- the column in the viewtype
- the type to which to coerce any edited values in the given column
public DsCellProperties getRowProperties(int row)
DsTable.getColumnProperties(int)
,
getCell()
public void setRowHeight(int row, int rowHeight)
row
to rowHeight
,
revalidates, and repaints. The height of the cells in this row
will be equal to the row height minus the row margin.
If using a row header it must be made visible prior to changing the row height.
setRowHeight
in class JTable
setRowHeaderVisible(boolean)
public void setRowHeight(int rowHeight)
rowHeight
,
revalidates, and repaints.
The height of the cells will be equal to the row height minus
the row margin.
If using a row header it must be made visible prior to changing the row height.
setRowHeight
in class JTable
setRowHeaderVisible(boolean)
public void addRow(Object item)
public void addRow()
public void insertRow(int index, String item)
public void removeRow(int index)
public void removeAll()
removeAll
in class Container
public void clear()
public void copyToClipboard()
public void copyToClipboard(boolean all, boolean includeColHeaders)
public void paste()
public String getClipString()
public void setClipString(String tabDelimtedStr)
public final boolean isSorted()
public void setSorted(boolean sort)
public final int getSortColumn()
public void setSortColumn(int modelIndex)
modelIndex
- The column index in the model to be sorted.public final int getSortOrder()
public void setSortOrder(int sortOrder)
sortOrder
- One of: ASCENDING, DESCENDING, ASCENDING_CASE, DESCENDING_CASEpublic void sort()
setSorted(boolean)
,
setSortColumn(int)
,
setSortOrder(int)
public void sort(int column, int sortOrder)
column
- column in the model to be sortedsortOrder
- One of: DsGrid.ASCENDING, DsGrid.DESCENDING, DsGrid.ASCENDING_CASE, DsGrid.DESCENDING_CASEpublic void setSortIcons(Icon ascendingSortIcon, Icon descendingSortIcon)
public final int getNumClicksToSort()
setNumClicksToSort(int)
,
setSorted(boolean)
public void setNumClicksToSort(int numClicks)
numClicks
- number of clicks required (either 0, 1, or 2)setSorted(boolean)
public void loadResultSet(ResultSet rs, boolean setHeaderColumns) throws SQLException
SQLException
public void loadResultSet(ResultSet rs, int begRow, int begCol, int endRow, int endCol) throws SQLException
SQLException
public void loadTabDelim(File file, boolean firstRowIsColHeader) throws FileNotFoundException, IOException
file
- File that provides the datafirstRowIsColHeader
- the first row is used to set the column headers
FileNotFoundException
IOException
public void loadTabDelim(Reader reader, boolean firstRowIsColHeader, boolean convertData) throws IOException
reader
- stream that provides the datafirstRowIsColHeader
- the first row is used to set the column headersconvertData
- attempt to parse the values into a Number, Boolean, Date in that order
IOException
public void loadCSV(File file, boolean firstRowIsColHeader) throws FileNotFoundException, IOException
file
- File that provides the datafirstRowIsColHeader
- the first row is used to set the column headers
FileNotFoundException
IOException
public void loadCSV(Reader reader, boolean firstRowIsColHeader, boolean convertData) throws IOException
reader
- stream that provides the datafirstRowIsColHeader
- the first row is used to set the column headersconvertData
- attempt to parse the values into a Number, Boolean, Date in that order
IOException
public void loadTextData(Reader reader, int begRow, int begCol, int endRow, int endCol, boolean firstRowIsColHeader, char delim, boolean stripStringDelim, boolean convertData) throws IOException
reader
- stream that provides the databegRow
- row position in model to begin placing databegCol
- column position in model to begin placing dataendRow
- ending row position in model to stop setting data. -1 means to load all data.endCol
- ending column position in model to stop setting data. -1 means to load all columns up to model.getColumnCount.firstRowIsColHeader
- the first row is used to set the column headersdelim
- delimeter used to separate values. Pass in '\t' for tab delimeted and ',' for csv.stripStringDelim
- removes the " at the beginning and end of stringsconvertData
- attempt to parse the values into a Number, Boolean, Date in that order
IOException
public void saveAsTabDelim(File file, boolean saveHeaderColumns) throws FileNotFoundException, IOException
file
- file that the data is saved tosaveHeaderColumns
- indicates whether the column names should be saved as the first row in the file
FileNotFoundException
IOException
public void saveAsCSV(File file, boolean saveHeaderColumns) throws FileNotFoundException, IOException
file
- file that the data is saved tosaveHeaderColumns
- indicates whether the column names should be saved as the first row in the file
FileNotFoundException
IOException
public void saveAsTextData(Writer writer, int begRow, int begCol, int endRow, int endCol, boolean saveHeaderColumns, char delim, boolean addStringDelim) throws IOException
writer
- stream that the data is saved tobegRow
- row position in model to begin saving databegCol
- column position in model to begin saving dataendRow
- ending row position in model to stop saving data. -1 means to save all data.endCol
- ending column position in model to stop saving data. -1 means to save all columns up to model.getColumnCount.delim
- delimeter added in between data elements in the same row. Pass in '\t' for tab delimeted and ',' for csv.addStringDelim
- Should a " be added around string data. Pass in false for tab delimeted and true for csv.
IOException
public void saveAsHTML(File file, boolean saveHeaderColumns) throws FileNotFoundException, IOException
file
- file that the data is saved tosaveHeaderColumns
- indicates whether the column names should be saved as the headers in the html table
FileNotFoundException
IOException
public void saveAsHTML(Writer writer, int begRow, int begCol, int endRow, int endCol, boolean saveHeaderColumns) throws IOException
writer
- stream that the data is saved tobegRow
- row position in model to begin saving databegCol
- column position in model to begin saving dataendRow
- ending row position in model to stop saving data. -1 means to save all data.endCol
- ending column position in model to stop saving data. -1 means to save all columns up to model.getColumnCount.saveHeaderColumns
- indicates whether the column names should be saved as the headers in the html table
IOException
public boolean print() throws PrinterException
print
in class JTable
PrinterException
public boolean print(boolean showPrintDialog, double scaleFactor, DsCellRange range, String footer, int showColumnHeader, int showRowHeader) throws PrinterException
showPrintDialog
- true will display the dialog to select a printer before printing.scaleFactor
- Make the grid smaller or larger when printed. -1 means scale the width to width of page if it is bigger. 1 means keep it the same size.range
- Range of cells to print. null means print entire gridfooter
- string the is printed on the bottom center of each pageshowColumnHeader
- display the ColumnHeader on the pages specified. One of: NONE, FIRST, ALLshowRowHeader
- display the RowHeader on the pages specified. One of: NONE, FIRST, ALL
Note: the footer string can include tokens that are replaced by the respective values. The following tokens are supported: &[Page] &[Pages] &[Date] &[Time]. If null is specified for the footer then "Page &[Page] of &[Pages]" is used.
PrinterException
public void printPreview()
public void printPreview(boolean showAllPages, double scaleFactor, DsCellRange range, String footer, int showColumnHeader, int showRowHeader)
showAllPages
- true will display all pages in a scrollable window. false will display one page at a time.scaleFactor
- Make the grid smaller or larger when printed. -1 means scale the width to width of page if it is bigger. 1 means keep it the same size.range
- Range of cells to print. null means print entire gridfooter
- string the is printed on the bottom center of each pageshowColumnHeader
- display the ColumnHeader on the pages specified. One of: NONE, FIRST, ALLshowRowHeader
- display the RowHeader on the pages specified. One of: NONE, FIRST, ALL
Note: the footer string can include tokens that are replaced by the respective values. The following tokens are supported: &[Page] &[Pages] &[Date] &[Time]. If null is specified for the footer then "Page &[Page] of &[Pages]" is used.
public boolean spanCells(int startRow, int startColumn, int rowsToSpan, int columnsToSpan)
startRow, startColumn
span
across rowsToSpan
rows and columnsToSpan
columns.
Once a cell has been spanned you will not be able to sort or reorder columns in the grid.
spanCells
in class DsTable
startRow
- The row of the cell which will span multiple rows and/or columnsstartColumn
- The column of the cell which will span multiple rows and/or columnsrowsToSpan
- The number of rows to span.columnsToSpan
- The number of columns to span.DsTable.removeSpan(int, int)
protected void fireColumnClicked(MouseEvent e)
public void addColumnClickListener(ColumnClickListener listener)
listener
- The ColumnClickListener to add.public void removeColumnClickListener(ColumnClickListener listener)
listener
- The ColumnClickListener to remove.public void addGridEditorListener(GridEditorListener l)
public void removeGridEditorListener(GridEditorListener l)
protected boolean fireGridEditorEvent(int eventType, int row, int col, Component editor)
public boolean isAutoRecalc()
recalcFormulas()
public void setAutoRecalc(boolean automaticallyRecalculateFormulas)
recalcFormulas()
public void recalcFormulas()
setFormulaAt(java.lang.String, int, int)
,
setAutoRecalc(boolean)
public void rowChanged(GridEvent e)
rowChanged
in interface GridRowListener
public void tableChanged(TableModelEvent e)
TableModel
generates
a TableModelEvent
.
Application code will not use these methods explicitly, they
are used internally by JTable
.
tableChanged
in interface TableModelListener
tableChanged
in class DsTable
public void valueChanged(ListSelectionEvent e)
valueChanged
in interface ListSelectionListener
valueChanged
in class DsTable
public Component prepareEditor(TableCellEditor editor, int row, int column)
prepareEditor
in class JTable
JTable.prepareEditor(javax.swing.table.TableCellEditor, int, int)
public void editingStopped(ChangeEvent e)
editingStopped
in interface CellEditorListener
editingStopped
in class JTable
JTable.editingStopped(javax.swing.event.ChangeEvent)
public void editingCanceled(ChangeEvent e)
editingCanceled
in interface CellEditorListener
editingCanceled
in class JTable
JTable.editingCanceled(javax.swing.event.ChangeEvent)
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void focusGained(FocusEvent e)
focusGained
in interface FocusListener
public void focusLost(FocusEvent e)
focusLost
in interface FocusListener
public void ensureVisible(int row)
public void ensureVisible(int row, int column)
public int getFirstVisibleColumn()
public int getFirstVisibleRow()
public int getTopVisibleRow()
getFirstVisibleRow()
public void addTableModelListener(TableModelListener l)
addTableModelListener
in interface TableModel
public void removeTableModelListener(TableModelListener l)
removeTableModelListener
in interface TableModel
public static void main(String[] args)
|
Diamond Control Suite 3.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |