|
||||||||||
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.JPanel quick.dbtable.DBTable
DBTable is a complete JTable alternative Javabean. DBTable can be used as
DBTable dBTable1 = new DBTable(); dBTable1.connectDatabase("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@myServer:1526:myInstance", "username" , "password"); dBTable1.setSelectSql("select * from employee"); dBTable1.refresh();
Navigation bar to navigate within the records is available, you need to call the
createControlPanel() method to create the navigation bar.
See How to use DBtable
See DBTable FAQ
See Don't forget to look at this sample which explains how to use DBTable.
Nested Class Summary |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Field Summary | |
static int |
ALL_NAVIGATION
navigation, insert, delete |
boolean |
autoCommit
If you want to handle the commit/rollback yourself, instead of quicktable handling it for you, set autoCommit to false. |
boolean |
copyColumnHeaderNames
While copying data from quickTable to clipboard, setting copyColumnHeaderNames will include column headers in the copied data. |
boolean |
debug
To get the debug messages , set this variable to true. |
int |
defaultClickCountToStartEditor
number of mouse clicks needed to start the editor. |
boolean |
doNotUseDatabaseSort
If you don't want to use the database query to sort the results and if you always want to sort by quicktable's sort set this to true |
boolean |
enableTextOverwriteOnCellEdit
If enableTextOverwriteOnCellEdit set to true, Whenever user starts editing a text cell, the previous value will be erased and the new value will be set. |
static int |
EQUAL
|
static int |
GREATER
|
static int |
LESS
|
boolean |
listenKeyPressEventsWholeWindow
Events like CTRL+F to open find window, HOME, END, PAGE DOWN etc are watched for the whole window where the dbTable is present. |
boolean |
postponeDBInsert
When you attach a DatabaseChangeListener with quicktable and during beforeInsert(), if you return false that means you don't want quickTable to do the insert, instead you will handle the database insert yourself. |
static int |
READ_DELETE_NAVIGATION
navigation, delete |
static int |
READ_INSERT_NAVIGATION
navigation, insert |
static int |
READ_NAVIGATION
navigation only |
boolean |
retainConnection
when you switch between the database bound modes and non bound modes, usually the database connections are closed next time when you go to the database bound mode, again a connection will be created. |
boolean |
showCriticalWarnings
QuickTable displays various critical warnings, which needs to be corrected by developers. |
boolean |
showFindReplaceMessages
While doing find or replace, quicktable shows informative messages like text not found, search complete, 10 replacements etc. |
static int |
UPDATE_DATABASE_ON_CELL_EXIT
By setting the setDatabaseUpdateMode() with this option, will save the changes to database once the user tries to go to a different cell than the currently edited cell |
static int |
UPDATE_DATABASE_ON_ROW_EXIT
By setting the setDatabaseUpdateMode() with this option, will save the changes to database once the user tries to go to a different row than the currently edited row |
Fields inherited from class javax.swing.JComponent |
TOOL_TIP_TEXT_KEY, 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 java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
DBTable()
Creates an empty table |
Method Summary | |
void |
addColumn(Column aColumn)
Deprecated. Developers are making mistakes in using this method,so use the safe method addColumn(String). If this method is already working fine for you then you can continue to use them. |
Column |
addColumn(java.lang.String headerText)
add a column to table. |
void |
addColumnSelectionInterval(int index0,
int index1)
Adds the columns from index0 to index0 inclusive to the current selection. |
void |
addDatabaseChangeListener(DatabaseChangeListener tc)
If you want to confirm the database insert/update/delete then add this listener. |
void |
addDBTableErrorListener(DBTableErrorListener yourListener)
If you want to handle the exceptions or errrors occured add this Listener. |
void |
addDBTableEventListener(DBTableEventListener yourListener)
Listen for various DBTable events |
void |
addDeleteSql(java.sql.CallableStatement deleteStatement,
java.lang.String columnPointer)
Sets the delete callable statement which is used delete the record from the table. |
void |
addDeleteSql(java.sql.PreparedStatement deleteStatement,
java.lang.String columnPointer)
Sets the delete prepared statement which is used delete the record from the table. |
void |
addDeleteSql(java.lang.String deleteStatement,
java.lang.String columnPointer)
Sets the delete statement which is used delete the record from the table. |
void |
addFocusListener(java.awt.event.FocusListener l)
|
void |
addInsertSql(java.sql.CallableStatement insertStatement,
java.lang.String columnPointer)
Sets the insert callable statement which is used to insert a record into table. |
void |
addInsertSql(java.sql.PreparedStatement insertStatement,
java.lang.String columnPointer)
Sets the insert prepared statement which is used to insert a record into table. |
void |
addInsertSql(java.lang.String insertStatement,
java.lang.String columnPointer)
Sets the insert statement which is used to insert a record into table. |
void |
addKeyListener(java.awt.event.KeyListener l)
|
void |
addMouseListener(java.awt.event.MouseListener l)
|
void |
addRowSelectionInterval(int index0,
int index1)
Adds the rows from index0 to index0 inclusive to the current selection. |
void |
addTableCellListener(DBTableCellListener tc)
This listener need to be added if you want to do cell data validation. |
void |
addUpdateSql(java.sql.CallableStatement updateStatement,
java.lang.String columnPointer)
Sets the update callable statement which is used to update data to the database when user changes values in the cells of table. |
void |
addUpdateSql(java.sql.CallableStatement updateStatement,
java.lang.String columnPointer,
int[] primaryColumns)
Sets the update callable statement which is used to update data to the database when user changes values in the cells of table. |
void |
addUpdateSql(java.sql.PreparedStatement updateStatement,
java.lang.String columnPointer)
Sets the update preparedstatement which is used to update data to the database when user changes values in the cells of table. |
void |
addUpdateSql(java.sql.PreparedStatement updateStatement,
java.lang.String columnPointer,
int[] primaryColumns)
Sets the update preparedstatement which is used to update data to the database when user changes values in the cells of table. |
void |
addUpdateSql(java.lang.String updateStatement,
java.lang.String columnPointer)
Sets the update statement which is used to update data to the database when user changes values in the cells of table. |
void |
addUpdateSql(java.lang.String updateStatement,
java.lang.String columnPointer,
int[] primaryColumns)
Sets the update statement which is used to update data to the database when user changes values in the cells of table. |
void |
cleanup()
Cleans up swing resources like frames used within DBTable. |
void |
clearAllDeleteSql()
clears all the delete sqls which were added using addDeleteSql method when you change the select sqls of a table and if you have assigned delete sqls before then we have to call this method which will clear all the old delete sqls, so that you can add new delete sqls for your new select sql |
void |
clearAllInsertSql()
clears all the insert sqls which were added using addInsertSql method when you change the select sqls of a table and if you have assigned insert sqls before then we have to call this method which will clear all the old insert sqls, so that you can add new insert sqls for your new select sql |
void |
clearAllSettings()
clears the currently used settings This clears the following UpdateSql InsertSql DeleteSql ErrorListener CellListener ChangeListener cellPropertiesModel Comparator |
void |
clearAllUpdateSql()
clears all the update sqls which were added using addUpdateSql method when you change the select sqls of a table and if you have assigned update sqls before then we have to call this method which will clear all the old update sqls, so that you can add new update sqls for your new select sql |
void |
clearSelection()
Deselects all selected columns and rows. |
void |
close()
Closes all the database resources |
static int |
compareObject(java.lang.Object o1,
java.lang.Object o2)
Utility method which can be used to compare two objects This method is added here, becuase it may be useful while implementing your own filter This method returns EQUAL, GREATER, LESS based on o1 compared with o2 |
void |
connectDatabase()
Makes the database connection You need to provide the database driver, jdbcurl, user, pass before calling this method |
void |
connectDatabase(java.lang.String dbDriver,
java.lang.String jdbcUrl,
java.lang.String user,
java.lang.String password)
Makes the database connection, using the specified parameters |
void |
copyToClipboard(int[] row)
Copies the content in the rows to clipboard, later it can be pasted in Excel or any text Editor. |
void |
createColumnModelFromQuery()
Creates the columnModel from the query, this uses ResultSetMetadata class to get the column properties. |
void |
createControlPanel()
Creates the control panel all the navigation buttons |
void |
createControlPanel(int type)
Creates the control panel based on the navigation types. |
void |
delete()
Deletes currently selected rows |
void |
delete(int[] rows)
Deletes the rows. |
void |
doFind()
Shows the find window, where user can enter the text to be found and does the find automatically If you want to do find programatically use find() method |
void |
doFindAndReplace()
Shows the find & replace window, where user can enter the text to be found and the replace string and the find & replace is done automatically If you want to do find and replace programatically use replace() method |
boolean |
editCellAt(int row,
int column)
Programmatically starts editing the cell at row and column, if the cell is editable. |
void |
enableExcelCopyPaste()
allows to do copy & paste from Excel into quicktable This option will work in applet only if applet has access to system clipboard. |
void |
filter(Filter filter)
Filters the data based on the given filter object If null is passed, then all the recorsd will be displayed |
void |
filter(int column,
int criteria,
java.lang.Object key)
Filters the data based on the given criteria |
java.awt.Point |
find(int r,
int colIndex,
java.lang.String findString1,
java.util.Vector searchCol,
boolean next)
Find searches for a given text and highlights the cell which contains the text |
java.awt.Point |
find(int r,
int colIndex,
java.lang.String findString1,
java.util.Vector searchCol,
boolean next,
int[] row)
Find searches for a given text in a given array of rows and highlights the cell which contains the text |
java.awt.Font |
findFont(java.lang.String sampleText)
A utility method to find the font which can display the given specific language text |
void |
fireTableCellUpdated(int row,
int column)
Notify all listeners that the value of the cell at (row, column) has been updated. |
void |
fireTableDataChanged()
Notify all listeners that all cell values in the table's rows may have changed. |
void |
first()
Selects the first row and makes sure first row is visible |
CellPropertiesModel |
getCellPropertiesModel()
gets the cellPropertiesModel of the table |
Column |
getColumn(int colIndex)
Returns the column object for the specified index. |
Column |
getColumnAsCreated(int colIndex)
Returns the column object for the specified index, as it was created. |
Column |
getColumnByDatabaseName(java.lang.String colName)
gets the Column based on the database column name If the column name is not found, this returns null |
Column |
getColumnByHeaderName(java.lang.String colName)
gets the Column based on the column header name If the column name is not found, this returns null |
int |
getColumnCount()
Returns the number of columns Source: Copied from JTable for convenience |
java.sql.Connection |
getConnection()
Returns the database Connection object used by the table |
javax.swing.JPanel |
getControlPanel()
returns the control panel, if one was ever created by calling createControlPanel() or setControlPanelVisible(). |
int |
getCurrentIndexForOriginalColumn(int colIndex)
If the columns have been moved/rearranged by the user, this method will return the new moved location of a original/created column index colIndex starts from 0,1,2,3... |
java.lang.Object[][] |
getDataArray()
Returns the quicktable data in a array |
java.lang.String |
getDatabaseDriver()
gets the database driver |
int |
getDatabaseUpdateMode()
gets the update mode about when the changes should be updated to database |
java.util.Vector |
getDataVector()
Returns the quicktable data in a Vector of Vector |
int |
getEditingColumn()
This returns the index of the editing column. |
int |
getEditingRow()
Returns the index of the editing row. |
javax.swing.JTable |
getFixedTable()
If you have created fixed columns using setFixedColumns(), then this method will return the JTable used by this fixed columns |
java.lang.String |
getJdbcUrl()
gets the JdbcUrl used |
int |
getMaximumRowCount()
returns the maximum row count |
int |
getOriginalColumnIndex(int colIndex)
If the columns have been moved/rearranged by the user, this method will return the original/created column index for a given (moved) column colIndex starts from 0,1,2,3... |
java.lang.String |
getPassword()
gets the password |
java.awt.print.Printable |
getPrintable(PrintProperties prop)
Gets the Printable for this table. |
PreviewPanel |
getPrintPreviewCanvas()
creates a printpreview Canvas This will be useful to create your own print preview frame |
PreviewPanel |
getPrintPreviewCanvas(int pageWidth,
int pageHeight)
creates a printpreview Canvas, with the paper size of given width & height. |
PreviewPanel |
getPrintPreviewCanvas(PrintProperties prop)
creates a printpreview Canvas with the given PrintProperties. |
int |
getRowCount()
Returns the number of rows in the table. |
java.lang.Object |
getRowObject(int row)
Gets the Data object in this row. |
int |
getSelectedColumn()
Returns the index of the first selected column, -1 if no column is selected. |
int |
getSelectedColumnCount()
Returns the number of selected columns. |
int[] |
getSelectedColumns()
Returns the indices of all selected columns. |
int |
getSelectedRow()
Returns the index of the first selected row, -1 if no row is selected. |
int |
getSelectedRowCount()
Returns the number of selected rows. |
int[] |
getSelectedRows()
Returns the indices of all selected rows. |
java.lang.String |
getSelectSql()
gets the select statement which is used to fetch data to be displayed in the table |
Skin |
getSkin()
Gets the current skin applied If no skin is assigned it returns null |
java.util.Vector |
getSortColumns()
returns a vector of Integer columns based on which the data is currently sorted. |
javax.swing.JTable |
getTable()
gets the JTable used by this DBTable You should use the returned JTable cautiously |
javax.swing.table.JTableHeader |
getTableHeader()
Returns the tableHeader working with this JTable. |
java.lang.String |
getUser()
gets the user name |
java.lang.Object |
getValueAt(int row,
int column)
Returns the cell value at row and column. |
java.lang.String |
getVersion()
returns the version of quicktable |
void |
goTo(int row)
Selects this row and makes sure this row is visible |
void |
insert(java.util.Vector insertElements)
Inserts the records into the Jtable. |
void |
insert(java.util.Vector insertElements,
int row)
Inserts the record at the given row into the Jtable. |
void |
insertEmptyRecord()
Inserts an empty records into the Jtable. |
void |
insertSilent(java.util.Vector insertElements,
int row)
Inserts the record at the given row into the Jtable. |
boolean |
isInsertingRow(int row)
From the time when the row was inserted into the table and until the inserted row was added to the database, this method will return true for that row. |
boolean |
isRowSelected(int row)
Returns true if the row at the specified index is selected Source: Copied from JTable for convenience |
boolean |
isSortAscending()
returns the current sort order |
void |
last()
Selects the last row and makes sure last row is visible |
void |
loadAllRows()
In some cases like when using database, quicktable loads data into table as user scrolls down to minimize memory usage This method will load all rows |
void |
moveColumn(int column,
int targetColumn)
Moves the column column to the position currently occupied by the column targetColumn. |
void |
next()
Selects the next row with respect to the currently selected row and makes sure that row is visible |
void |
pasteFromClipboard()
Paste the clipboard content into dbtable The content should be in a tab delimited format If you copy from Excel , it will be in a tab delimited format, else you can use a text editor |
void |
previous()
Selects the previous row with respect to the currently selected row and makes sure that row is visible |
void |
print()
Prints the contents of quicktable to printer This prints all the pages in portriat mode for A4 size paper If you want to print only specific pages use print(int[]) |
void |
print(int[] pages)
Prints the contents of quicktable to printer only for specific pages This prints in portriat mode for A4 size paper If you want to print all pages use print() |
void |
print(int[] pages,
int pageWidth,
int pageHeight)
Prints the contents of quicktable to printer with a paper size of pageWidth & pageHeight |
void |
print(int[] pages,
PrintProperties prop)
Prints the contents of quicktable to printer only for specific pages This prints based on the given Print properties If you want to print all pages use print(PrintProperties) |
void |
print(int pageWidth,
int pageHeight)
Prints the contents of quicktable to printer with a paper size of pageWidth & pageHeight |
void |
print(PrintProperties prop)
Prints the contents of quicktable to printer This prints all the pages using the given print properties If you want to print only specific pages use print(int[], PrintProperties) |
void |
printPreview()
Shows the print preview frame |
void |
printPreview(int pageWidth,
int pageHeight)
Shows the print preview frame, with the paper size of given width & height |
void |
printPreview(PrintProperties prop)
Shows the print preview frame for the given Print Properties |
void |
refresh()
This fires the query , and refills the table with the new data Note: This method should be used only when you have set a sql/stored procedure through setSelectSql In all the other cases call the other refresh() methods |
void |
refresh(java.io.BufferedReader in,
java.util.Properties prop)
loads a BufferedReader which contains delimited data |
void |
refresh(java.io.BufferedReader input,
java.lang.String delimiter)
loads a BufferedReader which contains delimited data |
void |
refresh(java.io.File f,
java.util.Properties prop)
loads a data file into quicktable |
void |
refresh(java.io.File f,
java.lang.String delimiter)
loads a delimited data file into quicktable |
void |
refresh(java.io.InputStream input,
java.util.Properties prop)
loads a inputstream which contains data to be loaded |
void |
refresh(java.io.InputStream input,
java.lang.String delimiter)
loads a inputstream which contains delimited data |
void |
refresh(java.lang.Object[][] input)
loads a two dimensional array of objects into quicktable |
void |
refresh(java.sql.ResultSet rs)
Loads the data from the resultset |
void |
refresh(java.net.URL url,
java.util.Properties prop)
loads a delimited file, found in the url into quicktable |
void |
refresh(java.net.URL url,
java.lang.String delimiter)
loads a delimited file, found in the url into quicktable |
void |
refresh(java.util.Vector input)
loads a two dimensional vector of objects into quicktable |
void |
refreshDataObject(java.util.Collection input,
java.lang.String[] methodNames)
loads a Collection of Data objects into quicktable |
void |
refreshDataObject(java.util.Enumeration input,
java.lang.String[] methodNames)
loads a enumeration of Data objects into quicktable |
void |
refreshDataObject(java.util.Vector input,
java.lang.String[] methodNames)
loads a Vector of Data objects into quicktable |
void |
refreshSkin()
The skin assigned to the table through setSkin() method will be applied to the table This method should be called only if you feel that the skin is not getting refreshed |
void |
removeAllRows()
Clears all data which is currently shown in the table. |
void |
removeColumn(Column aColumn)
|
void |
removeColumnHeader()
Removes the column header from the table |
void |
removeColumnSelectionInterval(int index0,
int index1)
Deselects the columns from index0 to index0 inclusive. |
void |
removeDatabaseChangeListener(DatabaseChangeListener tc)
|
void |
removeDBTableErrorListener(DBTableErrorListener yourListener)
|
void |
removeDBTableEventListener(DBTableEventListener yourListener)
|
void |
removeFocusListener(java.awt.event.FocusListener l)
|
void |
removeKeyListener(java.awt.event.KeyListener l)
|
void |
removeMouseListener(java.awt.event.MouseListener l)
|
void |
removeNotify()
|
void |
removeRowSelectionInterval(int index0,
int index1)
Deselects the rows from index0 to index0 inclusive. |
void |
removeTableCellListener(DBTableCellListener tc)
|
java.awt.Point |
replace(int r,
int colIndex,
java.lang.String findString1,
java.lang.String replaceString,
java.util.Vector searchCol,
boolean next)
replace searches for a text , highlights the cell and prompts you whether you want to replace the text |
java.awt.Point |
replace(int r,
int colIndex,
java.lang.String findString1,
java.lang.String replaceString,
java.util.Vector searchCol,
boolean next,
int[] row)
replace searches for a text , highlights the cell and prompts you whether you want to replace the text |
java.awt.Point |
replaceAll(int r,
int colIndex,
java.lang.String findString1,
java.lang.String replaceString,
java.util.Vector searchCol)
replaceAll searches for a text , once the text is found it is replaced without confirmation and all occurences are replaced |
java.awt.Point |
replaceAll(int r,
int colIndex,
java.lang.String findString1,
java.lang.String replaceString,
java.util.Vector searchCol,
int[] row)
replaceAll searches for a text , once the text is found it is replaced without confirmation and all occurences are replaced |
void |
save()
Usually changes are saved automatically when the selection of row changes This method saves any pending insert or updates |
void |
scrollToCell(int row,
int column)
If this cell is currently not visible, the view will be scrolled to show the cell |
void |
selectAll()
Select all rows, columns and cells in the table. |
void |
selectCell(int rowOfCellToBeSelected,
int columnOfCellToBeSelected)
selects the cell. |
void |
selectCell(int rowOfCellToBeSelected,
int columnOfCellToBeSelected,
boolean focus)
|
void |
selectFirstVisibleColumnCell(int row,
boolean focus)
|
void |
setCellComponent(Column c,
int cellType,
java.util.Hashtable cellValueToDisplayHash)
sets the column's cell's component for rendering and editing. |
void |
setCellComponent(Column c,
int cellType,
java.util.Hashtable cellValueToDisplayHash,
boolean addClearOption)
sets the column's cell's component for rendering and editing See the documentation of the other method for more information, setCellComponent(Column, int , Hashtable) The only difference than the other method is, you can add an empty cell to select null values |
void |
setCellComponent(Column c,
int cellType,
java.util.Hashtable cellValueToDisplayHash,
java.lang.Object[] keysSortOrder,
boolean addClearOption)
sets the column's cell's component for rendering and editing See the documentation of the other method for more information, setCellComponent(Column, int , Hashtable) The only difference than the other method is, you can sort the combo box listed items using keysSortOrder. |
void |
setCellPropertiesModel(CellPropertiesModel cellModel)
Sets the cellPropertiesModel for the table. |
void |
setComparator(Comparator comp)
Sets the compartor which should be used for sorting |
void |
setConnection(java.sql.Connection newConnection)
Sets the database Connection object to be used by this table |
void |
setControlPanelVisible(boolean visible)
show/hide the control panel |
void |
setDatabaseDriver(java.lang.String input)
Sets the database driver |
void |
setDatabaseUpdateMode(int mode)
sets the update mode about when the changes should be updated to database |
void |
setDBTableLocale(java.util.Locale currentLocale)
sets the locale for quickTable. |
void |
setDBTableLocale(java.util.Locale currentLocale,
java.awt.Font localeFont)
sets the locale for quickTable. |
void |
setDBTableLocale(java.util.Locale currentLocale,
java.lang.String localeUnicodeText)
sets the locale for quickTable. |
void |
setEditable(boolean val)
sets the editable property of this table. |
void |
setFixedColumns(int[] cols)
Sets the fixed columns. |
void |
setJdbcUrl(java.lang.String input)
Sets the jdbc url |
void |
setMaximumRowCount(int row)
sets the maximum rows which QuickTable will load, even though the source may have more rows Example a query returns 1000 records & you want to show only first 100 records This method should be called before you call refresh() This method won't set the maximum row, when the source is array or vector After setting the maximum row count, if you have to change back to the original behaviour of showing all availble records use setMaximumRowCount(java.lang.Integer.MAX_VALUE) |
void |
setPassword(java.lang.String input)
Sets the password |
void |
setRowCountSql(java.lang.String rowCountSql)
Sets the sql which is used to calculate the total rows available for the current select sql |
void |
setRowSelectionInterval(int index0,
int index1)
Selects the rows from index0 to index1 inclusive. |
void |
setSelectSql(java.lang.String input)
Sets the select sql or stored procedure which should be used to fetch data to be displayed in the table The column properties will be refreshed from database everytime the Select sql is changed using this method |
void |
setSkin(Skin skin)
Apply the skin to table. |
void |
setSortEnabled(boolean val)
If you don't want quicktable to do its default sort,when the user clicks on column header, pass false |
void |
setSorter(Sorter sorter)
Sets the sorter which should be used for sorting |
void |
setUser(java.lang.String input)
Sets the user |
void |
setValueAt(java.lang.Object aValue,
int row,
int column)
Sets the value for the cell at row and column. |
void |
sortByColumn(int column,
boolean ascending)
Sorts the data by the given column Note:In Mac OS, sorting will not show the sort type icon in header |
void |
sortByColumns(java.util.Vector columnVector,
boolean ascending)
Sorts the data by many columns Note:In Mac OS, sorting will not show the sort type icon in header |
void |
update(int row,
int col,
java.lang.Object value)
updates the cell with the new value this update is also done in the database |
void |
useOldColumnProperties(boolean val)
to set whether column properties should be recreated or not The column properties will be refreshed from database based on useOldColumnProperties argument |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public boolean debug
public boolean showCriticalWarnings
public boolean showFindReplaceMessages
public boolean retainConnection
public static final int ALL_NAVIGATION
public static final int READ_INSERT_NAVIGATION
public static final int READ_DELETE_NAVIGATION
public static final int READ_NAVIGATION
public static final int UPDATE_DATABASE_ON_ROW_EXIT
public static final int UPDATE_DATABASE_ON_CELL_EXIT
public boolean autoCommit
public boolean copyColumnHeaderNames
public boolean enableTextOverwriteOnCellEdit
public boolean listenKeyPressEventsWholeWindow
public boolean postponeDBInsert
DatabaseChangeListener.beforeInsert(int)
public int defaultClickCountToStartEditor
If you want to change this per column, then use dbTable.getColumn(i).getCellEditor().setClickCountToStart(j); If you want to modify the value of this variable, it should be done immediately after you instantiate DBTable. The default value is 1. when user clicks on a cell, if the cell is editable, cell editor will be immediately shown. You can change this to 2, if you want the editor to be shown only on double click.
public boolean doNotUseDatabaseSort
public static final int EQUAL
public static final int GREATER
public static final int LESS
Constructor Detail |
public DBTable()
Method Detail |
public void createControlPanel()
public void setControlPanelVisible(boolean visible)
public javax.swing.JPanel getControlPanel()
public void createControlPanel(int type)
ALL_NAVIGATION -- navigation, insert, delete READ_INSERT_NAVIGATION -- navigation, insert READ_DELETE_NAVIGATION -- navigation, delete READ_NAVIGATION -- navigation
public void delete()
public void scrollToCell(int row, int column)
public void goTo(int row)
public void first()
public void last()
public void previous()
public void next()
public void setSortEnabled(boolean val)
public void delete(int[] rows) throws java.lang.Exception
rows
- array of rownumbers , the row numbers start from 0,1,2..
java.lang.Exception
public void insert(java.util.Vector insertElements)
This doesn't inserts into database Insertion into database occurs when 1) the user moves away from this record by selecting another row 2) closing the table 3) by calling save() method Example : the columns are EmpNo, EmpName and you want to set empNo=10, empName="Alice" Vector insertVector = new Vector(); //since first column is empNo, insert that value first into the vector insertVector.addElement(new Integer(10)); //add the second columnvalue insertVector.addElement("Alice"); yourDBTableInstance.insert(insertVector);If the table is not in editable mode, insert will not work. use setEditable() to change settings
insertElements
- a vector whose elements are the cell values
and the elements should be in the same order of columnspublic void insert(java.util.Vector insertElements, int row)
This doesn't inserts into database Insertion into database occurs when 1) the user moves away from this record by selecting another row 2) closing the table 3) by calling save() method Example : the columns are EmpNo, EmpName and you want to set empNo=10, empName="Alice" Vector insertVector = new Vector(); //since first column is empNo, insert that value first into the vector insertVector.addElement(new Integer(10)); //add the second columnvalue insertVector.addElement("Alice"); yourDBTableInstance.insert(insertVector,3);
insertElements
- a vector whose elements are the cell values
and the elements should be in the same order of columnsrow
- The row where this record should be inserted. Valid values for row would be 0 to rowcount-1public void insertSilent(java.util.Vector insertElements, int row)
insertElements
- a vector whose elements are the cell values
and the elements should be in the same order of columnsrow
- The row where this record should be inserted. Valid values for row would be 0 to rowcount-1public void insertEmptyRecord()
This doesn't inserts into database Insertion into database occurs when 1) the user moves away from this record by selecting another row 2) closing the table 3) by calling save() method
public void setDatabaseDriver(java.lang.String input)
input
- name of the driver e.g oracle.jdbc.driver.OracleDriver (sample)
refer to your jdbc driver documentation for exact driver namepublic java.lang.String getDatabaseDriver()
public void setJdbcUrl(java.lang.String input)
input
- jdbc url
The standard syntax for JDBC URLs is shown below. It has three parts, which are
separated by colons:
jdbc:public java.lang.String getJdbcUrl()
public void setUser(java.lang.String input)
input
- the user name to be used to logon to databasepublic java.lang.String getUser()
public void setPassword(java.lang.String input)
input
- the password to be used to logon to databasepublic java.lang.String getPassword()
public java.lang.String getSelectSql()
public javax.swing.JTable getTable()
public void addUpdateSql(java.lang.String updateStatement, java.lang.String columnPointer)
Since the select statemnt used for this table may use table join or use a subquery, we may need to update more than one table, so more than one update statements are needed. So you can add as many updateStatements as needed using this method Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a, emp_status b where a.emp_no = b.emp_no" If the user changes the emp_name & status in a record, then we need to update 2 tables update emp set emp_name =[new emp_name] where emp_no = [emp_no] update emp_status set status=[new status] where emp_no=[emp_no] To set this , you need to call this method as addUpdateSql("update emp set emp_name =? where emp_no =?", "2,1"); addUpdateSql("update emp_status set status=? where emp_no=?, "3,1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted in the sql Statement. In the first Sql Statement we wanted to substitute emp_name which is second column in the table to the first question mark position in the sql & then the emp_no, which is first column in the table to the second question mark position in the sql, so we gave the column pointer value as "2,1". Note the column numbers should be seperated by "Comma" if you specify more than one update statement then transaction will be commited only if all the update statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addUpdateSql(preparedStatement1, arr) addUpdateSql(preparedStatement2, arr2) case 2: addUpdateSql(preparedStatement1, arr) addUpdateSql(callableStatement2, arr2) case 3: addUpdateSql(callableStatement1, arr) addUpdateSql(callableStatement2, arr2) * case 4: addUpdateSql(preparedStatement1, arr) addUpdateSql(sqlString, arr2) case 5: addUpdateSql(sqlString, arr2) addUpdateSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllUpdateSql()
updateStatement
- The update statement to be added (this sql should be preparable)columnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllUpdateSql()
,
addUpdateSql(PreparedStatement , String )
,
addUpdateSql(CallableStatement , String )
public void addUpdateSql(java.lang.String updateStatement, java.lang.String columnPointer, int[] primaryColumns)
Since the select statemnt used for this table may use table join or use a subquery, we may need to update more than one table, so more than one update statements are needed. So you can add as many updateStatements as needed using this method Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a, emp_status b where a.emp_no = b.emp_no" If the user changes the emp_name & status in a record, then we need to update 2 tables update emp set emp_name =[new emp_name] where emp_no = [emp_no] update emp_status set status=[new status] where emp_no=[emp_no] To set this , you need to call this method as addUpdateSql("update emp set emp_name =? where emp_no =?", "2,1"); addUpdateSql("update emp_status set status=? where emp_no=?, "3,1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted in the sql Statement. In the first Sql Statement we wanted to substitute emp_name which is second column in the table to the first question mark position in the sql & then the emp_no, which is first column in the table to the second question mark position in the sql, so we gave the column pointer value as "2,1". Note the column numbers should be seperated by "Comma" if you specify more than one update statement then transaction will be commited only if all the update statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addUpdateSql(preparedStatement1, arr) addUpdateSql(preparedStatement2, arr2) case 2: addUpdateSql(preparedStatement1, arr) addUpdateSql(callableStatement2, arr2) case 3: addUpdateSql(callableStatement1, arr) addUpdateSql(callableStatement2, arr2) * case 4: addUpdateSql(preparedStatement1, arr) addUpdateSql(sqlString, arr2) case 5: addUpdateSql(sqlString, arr2) addUpdateSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllUpdateSql() primaryColumns Sometimes the jdbc drives don't exactly give information about which columns are primary columns. primaryColumns information is necessary when users are allowed to modify primary columns values. In the above example emp_no is the primary key and emp_no is the first column, so primaryColumns will be new int[]{1} If first two columns are primary columns, then new int[]{1,2}
updateStatement
- The update statement to be added (this sql should be preparable)columnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.primaryColumns
- array of primary column numbersclearAllUpdateSql()
,
addUpdateSql(PreparedStatement , String )
,
addUpdateSql(CallableStatement , String )
public void addUpdateSql(java.sql.PreparedStatement updateStatement, java.lang.String columnPointer, int[] primaryColumns)
Since the select statemnt used for this table may use table join or use a subquery, we may need to update more than one table, so more than one update statements are needed. So you can add as many updateStatements as needed using this method Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a, emp_status b where a.emp_no = b.emp_no" If the user changes the emp_name & status in a record, then we need to update 2 tables update emp set emp_name =[new emp_name] where emp_no = [emp_no] update emp_status set status=[new status] where emp_no=[emp_no] To set this , you need to call this method as addUpdateSql(yourDBConnection.prepareStatement("update emp set emp_name =? where emp_no =?"), "2,1"); addUpdateSql(yourDBConnection.prepareStatement("update emp_status set status=? where emp_no=?), "3,1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one update statement then transaction will be commited only if all the update statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addUpdateSql(preparedStatement1, arr) addUpdateSql(preparedStatement2, arr2) case 2: addUpdateSql(preparedStatement1, arr) addUpdateSql(callableStatement2, arr2) case 3: addUpdateSql(callableStatement1, arr) addUpdateSql(callableStatement2, arr2) * case 4: addUpdateSql(preparedStatement1, arr) addUpdateSql(sqlString, arr2) case 5: addUpdateSql(sqlString, arr2) addUpdateSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllUpdateSql() primaryColumns Sometimes the jdbc drives don't exactly give information about which columns are primary columns. primaryColumns information is necessary when users are allowed to modify primary columns values. In the above example emp_no is the primary key and emp_no is the first column, so primaryColumns will be new int[]{1} If first two columns are primary columns, then new int[]{1,2}
updateStatement
- The update preparedstatement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.primaryColumns
- array of primary column numbersclearAllUpdateSql()
,
addUpdateSql(String , String )
,
addUpdateSql(CallableStatement , String )
public void addUpdateSql(java.sql.PreparedStatement updateStatement, java.lang.String columnPointer)
Since the select statemnt used for this table may use table join or use a subquery, we may need to update more than one table, so more than one update statements are needed. So you can add as many updateStatements as needed using this method Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a, emp_status b where a.emp_no = b.emp_no" If the user changes the emp_name & status in a record, then we need to update 2 tables update emp set emp_name =[new emp_name] where emp_no = [emp_no] update emp_status set status=[new status] where emp_no=[emp_no] To set this , you need to call this method as addUpdateSql(yourDBConnection.prepareStatement("update emp set emp_name =? where emp_no =?"), "2,1"); addUpdateSql(yourDBConnection.prepareStatement("update emp_status set status=? where emp_no=?), "3,1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one update statement then transaction will be commited only if all the update statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addUpdateSql(preparedStatement1, arr) addUpdateSql(preparedStatement2, arr2) case 2: addUpdateSql(preparedStatement1, arr) addUpdateSql(callableStatement2, arr2) case 3: addUpdateSql(callableStatement1, arr) addUpdateSql(callableStatement2, arr2) * case 4: addUpdateSql(preparedStatement1, arr) addUpdateSql(sqlString, arr2) case 5: addUpdateSql(sqlString, arr2) addUpdateSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllUpdateSql()
updateStatement
- The update preparedstatement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllUpdateSql()
,
addUpdateSql(String , String )
,
addUpdateSql(CallableStatement , String )
public void addUpdateSql(java.sql.CallableStatement updateStatement, java.lang.String columnPointer)
Example addUpdateSql(yourDBConnection.prepareCall("updateEmployeeInfo(?,?)"), "2,1"); addUpdateSql(yourDBConnection.prepareCall("updateEmployeeStatus(?,?)"), "3,1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one update statement then transaction will be commited only if all the update statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addUpdateSql(preparedStatement1, arr) addUpdateSql(preparedStatement2, arr2) case 2: addUpdateSql(preparedStatement1, arr) addUpdateSql(callableStatement2, arr2) case 3: addUpdateSql(callableStatement1, arr) addUpdateSql(callableStatement2, arr2) * case 4: addUpdateSql(preparedStatement1, arr) addUpdateSql(sqlString, arr2) case 5: addUpdateSql(sqlString, arr2) addUpdateSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllUpdateSql()
updateStatement
- The update callable statement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllUpdateSql()
,
addUpdateSql(String , String )
,
addUpdateSql(PreparedStatement , String )
public void addUpdateSql(java.sql.CallableStatement updateStatement, java.lang.String columnPointer, int[] primaryColumns)
Example addUpdateSql(yourDBConnection.prepareCall("updateEmployeeInfo(?,?)"), "2,1"); addUpdateSql(yourDBConnection.prepareCall("updateEmployeeStatus(?,?)"), "3,1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one update statement then transaction will be commited only if all the update statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addUpdateSql(preparedStatement1, arr) addUpdateSql(preparedStatement2, arr2) case 2: addUpdateSql(preparedStatement1, arr) addUpdateSql(callableStatement2, arr2) case 3: addUpdateSql(callableStatement1, arr) addUpdateSql(callableStatement2, arr2) * case 4: addUpdateSql(preparedStatement1, arr) addUpdateSql(sqlString, arr2) case 5: addUpdateSql(sqlString, arr2) addUpdateSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllUpdateSql() primaryColumns Sometimes the jdbc drives don't exactly give information about which columns are primary columns. primaryColumns information is necessary when users are allowed to modify primary columns values. In the above example emp_no is the primary key and emp_no is the first column, so primaryColumns will be new int[]{1} If first two columns are primary columns, then new int[]{1,2}
updateStatement
- The update callable statement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.primaryColumns
- array of primary column numbersclearAllUpdateSql()
,
addUpdateSql(String , String )
,
addUpdateSql(PreparedStatement , String )
public void addDeleteSql(java.lang.String deleteStatement, java.lang.String columnPointer)
Since the select statemnt used for this table may use table join or use a subquery, we may need to delete records in more than one table, so more than one delete statements are needed. So you can add as many updateStatements as needed using this method. Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a,emp_status b where a.emp_no = b.emp_no" If the user deletes a displayed record, then we need to delete records in 2 tables delete from emp where emp_no = [emp_no] delete from emp_status where emp_no = [emp_no] To set this , you need to call this method as addDeleteSql("delete from emp where emp_no = ?", "1"); addDeleteSql("delete from emp_status where emp_no = ?", "1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted in the sql Statement. In the first Sql Statement we wanted to substitute the emp_no, which is first column in the table to the first question mark position in the sql so we gave the column pointer value as "1". if there is more than one column we need to seperate with "Comma" , example "1,3,4". if you specify more than one delete statement then transaction will be commited only if all the delete statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addDeleteSql(preparedStatement1, arr) addDeleteSql(preparedStatement2, arr2) case 2: addDeleteSql(preparedStatement1, arr) addDeleteSql(callableStatement2, arr2) case 3: addDeleteSql(callableStatement1, arr) addDeleteSql(callableStatement2, arr2) * case 4: addDeleteSql(preparedStatement1, arr) addDeleteSql(sqlString, arr2) case 5: addDeleteSql(sqlString, arr2) addDeleteSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllDeleteSql()
deleteStatement
- The delete statement to be added (this sql should be preparable)columnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllDeleteSql()
,
addDeleteSql(CallableStatement , String )
,
addDeleteSql(PreparedStatement , String )
public void addDeleteSql(java.sql.PreparedStatement deleteStatement, java.lang.String columnPointer)
Since the select statemnt used for this table may use table join or use a subquery, we may need to delete records in more than one table, so more than one delete statements are needed. So you can add as many updateStatements as needed using this method. Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a,emp_status b where a.emp_no = b.emp_no" If the user deletes a displayed record, then we need to delete records in 2 tables delete from emp where emp_no = [emp_no] delete from emp_status where emp_no = [emp_no] To set this , you need to call this method as addDeleteSql(yourDBConnection.prepareStatement("delete from emp where emp_no = ?"), "1"); addDeleteSql(yourDBConnection.prepareStatement("delete from emp_status where emp_no = ?"), "1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one delete statement then transaction will be commited only if all the delete statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addDeleteSql(preparedStatement1, arr) addDeleteSql(preparedStatement2, arr2) case 2: addDeleteSql(preparedStatement1, arr) addDeleteSql(callableStatement2, arr2) case 3: addDeleteSql(callableStatement1, arr) addDeleteSql(callableStatement2, arr2) * case 4: addDeleteSql(preparedStatement1, arr) addDeleteSql(sqlString, arr2) case 5: addDeleteSql(sqlString, arr2) addDeleteSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllDeleteSql()
deleteStatement
- The delete preparedstatement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllDeleteSql()
,
addDeleteSql(CallableStatement , String )
,
addDeleteSql(String , String )
public void addDeleteSql(java.sql.CallableStatement deleteStatement, java.lang.String columnPointer)
Example addDeleteSql(yourDBConnection.prepareCall("deleteEmployeeInfo(?)"), "1"); addDeleteSql(yourDBConnection.prepareCall("deleteEmployeeStatus(?)"), "1"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one delete statement then transaction will be commited only if all the delete statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addDeleteSql(preparedStatement1, arr) addDeleteSql(preparedStatement2, arr2) case 2: addDeleteSql(preparedStatement1, arr) addDeleteSql(callableStatement2, arr2) case 3: addDeleteSql(callableStatement1, arr) addDeleteSql(callableStatement2, arr2) * case 4: addDeleteSql(preparedStatement1, arr) addDeleteSql(sqlString, arr2) case 5: addDeleteSql(sqlString, arr2) addDeleteSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllDeleteSql()
deleteStatement
- The delete callable statement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllDeleteSql()
,
addDeleteSql(PreparedStatement , String )
,
addDeleteSql(String , String )
public void addInsertSql(java.lang.String insertStatement, java.lang.String columnPointer)
Since the select statemnt used for this table may use table join or use a subquery, we may need to insert record into more than one table, so more than one insert statementa are needed. You can add any number of insert statements using this method Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a, emp_status b where a.emp_no = b.emp_no" If the user inserts a record , the following statments need to be executed insert into emp (emp_no, emp_name) values ([emp_no], [emp_name]); insert into emp_status (emp_no, emp_status) values ([emp_no], [emp_status]); To set this , you need to call this method as addInsertSql("insert into emp (emp_no, emp_name) values (?,?)", "1,2"); addInsertSql("insert into emp_status (emp_no, emp_status) values (?, ?)", "1,3"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted in the sql Statement. In the first Sql Statement we wanted to substitute the emp_no, which is first column in the table to the first question mark position in the sql and then emp_name which is second column in the table to the second question mark position in the sql , so we gave the column pointer value as "1,2". Note the column numbers should be seperated by "Comma" if you specify more than one insert statement then transaction will be commited only if all the insert statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addInsertSql(preparedStatement1, arr) addInsertSql(preparedStatement2, arr2) case 2: addInsertSql(preparedStatement1, arr) addInsertSql(callableStatement2, arr2) case 3: addInsertSql(callableStatement1, arr) addInsertSql(callableStatement2, arr2) * case 4: addInsertSql(preparedStatement1, arr) addInsertSql(sqlString, arr2) case 5: addInsertSql(sqlString, arr2) addInsertSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllInsertSql()
insertStatement
- The insert statement to be added (this sql should be preparable)columnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllInsertSql()
public void addInsertSql(java.sql.PreparedStatement insertStatement, java.lang.String columnPointer)
Since the select statemnt used for this table may use table join or use a subquery, we may need to insert record into more than one table, so more than one insert statementa are needed. You can add any number of insert statements using this method Lets say your selectSql is "select a.emp_no, a.emp_name, b.status from emp a, emp_status b where a.emp_no = b.emp_no" If the user inserts a record , the following statments need to be executed insert into emp (emp_no, emp_name) values ([emp_no], [emp_name]); insert into emp_status (emp_no, emp_status) values ([emp_no], [emp_status]); To set this , you need to call this method as addInsertSql(yourDBConnection.prepareStatement("insert into emp (emp_no, emp_name) values (?,?)"), "1,2"); addInsertSql(yourDBConnection.prepareStatement("insert into emp_status (emp_no, emp_status) values (?, ?)")fs, "1,3"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one insert statement then transaction will be commited only if all the insert statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addInsertSql(preparedStatement1, arr) addInsertSql(preparedStatement2, arr2) case 2: addInsertSql(preparedStatement1, arr) addInsertSql(callableStatement2, arr2) case 3: addInsertSql(callableStatement1, arr) addInsertSql(callableStatement2, arr2) * case 4: addInsertSql(preparedStatement1, arr) addInsertSql(sqlString, arr2) case 5: addInsertSql(sqlString, arr2) addInsertSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllInsertSql()
insertStatement
- The insert prepared statement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllInsertSql()
,
addInsertSql(CallableStatement , String )
,
addInsertSql(String , String )
public void addInsertSql(java.sql.CallableStatement insertStatement, java.lang.String columnPointer)
Example addInsertSql(yourDBConnection.prepareCall("insertEmployeeInfo(?,?)"), "1,2"); addInsertSql(yourDBConnection.prepareCall("insertEmployeeStatus(?, ?)"), "1,3"); The second argument to this method is a column pointer which tells how the cell values in the table should be substituted for the input parameters if you specify more than one insert statement then transaction will be commited only if all the insert statements go through fine The order in which the statements will be executed will be the order in which you added Note: For a given select sql, you can either use "preparedStatement or callable statement" or sql string, you cannot mix, meaning, case 1: addInsertSql(preparedStatement1, arr) addInsertSql(preparedStatement2, arr2) case 2: addInsertSql(preparedStatement1, arr) addInsertSql(callableStatement2, arr2) case 3: addInsertSql(callableStatement1, arr) addInsertSql(callableStatement2, arr2) * case 4: addInsertSql(preparedStatement1, arr) addInsertSql(sqlString, arr2) case 5: addInsertSql(sqlString, arr2) addInsertSql(preparedStatement1, arr) case 1 & 2 & 3 are valid, case 4 & 5 are invalid If you change the selectSql of the quicktable to a entirely different query to which the update/insert/delete statements are not applicable, don't forget to clear the existing update Sqls using clearAllInsertSql()
insertStatement
- The insert prepared statement to be addedcolumnPointer
- columnNumbers whose values should be set for this sql, the column numbers starts as 1,2,3
The column numbers should be seperated by comma
the column numbers should be of the same order of parameter you specify in sql.clearAllInsertSql()
,
addInsertSql(PreparedStatement , String )
,
addInsertSql(String , String )
public java.sql.Connection getConnection()
public void setConnection(java.sql.Connection newConnection)
newConnection
- public void connectDatabase() throws java.sql.SQLException, java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundException
public void connectDatabase(java.lang.String dbDriver, java.lang.String jdbcUrl, java.lang.String user, java.lang.String password) throws java.sql.SQLException, java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundException
public Column getColumn(int colIndex)
If the user has moved columns then this method will return the new columns. If you want to get the columns as you created ( without user rearranging changes) then use the getOriginalColumn() method If the column is not available then you will get a RuntimeException Column x is not available . This can happen if you call this method prematurely. when using database either refresh(..) or createColunModelFromQuery() should be called before calling getColumn() method. In other modes, one of the refresh methods should be called before calling getColumn()
colIndex
- getColumnAsCreated(int)
public Column getColumnAsCreated(int colIndex)
If you want to access the column with index as it is seen now use getColumn() methodcolIndex starts from 0,1,2,3...
colIndex
- public int getOriginalColumnIndex(int colIndex)
colIndex
-
public int getCurrentIndexForOriginalColumn(int colIndex)
colIndex
-
public void addColumn(Column aColumn)
Column c = new Column(dBTable1.getColumnCount()+1); c.setHeaderValue("Order\nNo."); c.setLength(25); c.setPreferredWidth(100); dBTable1.addColumn(c);Restriction: addColumn() method cannot be called before calling any refresh(...) type methods or createColumnModelFromQuery() method
aColumn
- addColumn(String)
public Column addColumn(java.lang.String headerText)
headerText
- public void removeColumn(Column aColumn)
public void removeAllRows()
public void setSelectSql(java.lang.String input)
Example for executing stored procedure dBTable1.setSelectSql("get_Company_Info IBM, 2"); Note: whenever the select sql of the dbtable is changed by calling this method, the next time when you call refresh() to fecth data, the column properties will be reset based on database column properties. e.g case 1: setSelectsql("select * from Orders"); refresh(); // column properties are assigned based on the database column properties for orders setSelectsql("select * from products"); refresh(); // column properties for orders are lost & new column properties are assigned based on the database column properties for products case 2: setSelectsql("select * from Orders where dept=123"); refresh(); // column properties are assigned based on the database column properties for orders setSelectsql("select * from Orders where amount>5000"); refresh(); // column properties for orders are lost & new column properties are assigned based on the database column properties for orders In case 2 we don't need to recreate the column properties second time, since they have the same column properties, use the following setSelectsql("select * from Orders where dept=123"); refresh(); // column properties are assigned based on the database column properties for orders setSelectsql("select * from Orders where amount>5000"); useOldColumnProperties(true); refresh(); // column properties for orders will be used again
input
- the select sql / stored procedureuseOldColumnProperties( boolean)
public void setRowCountSql(java.lang.String rowCountSql)
Usually rowcount sqls are automatically created, but when you use stored procedure or complex sql we cannot automatically create rowCountSql. In those cases you can set the rowCountSql Example setSelectsql("select * from Orders where dept=123"); dBTable1.setRowCountSql("select count(*) from Orders where dept=123"); dBTable1.refresh(); Note: If you have assigned rowCountSql currently and for the next selectsql, if you want quicktable to automatically create rowCountsql then set setRowCountSql(null) before calling refresh(), otherwise old rowCountSql will be used.
rowCountSql
- the row count sql / stored procedurepublic void useOldColumnProperties(boolean val)
Note: The following cases compare the difference between this method and the other setSelectSql method e.g case 1: setSelectsql("select * from Orders"); refresh(); // column properties are assigned based on the database column properties for orders setSelectsql("select * from products"); refresh(); // column properties for orders are lost & new column properties are assigned based on the database column properties for products case 2: setSelectsql("select * from Orders where dept=123"); refresh(); // column properties are assigned based on the database column properties for orders setSelectsql("select * from Orders where amount>5000"); refresh(); // column properties for orders are lost & new column properties are assigned based on the database column properties for orders In case 2 we don't need to recreate the column properties second time, since they have the same column properties, use the following setSelectsql("select * from Orders where dept=123"); refresh(); // column properties are assigned based on the database column properties for orders setSelectsql("select * from Orders where amount>5000" ); useOldColumnProperties(true); refresh(); // column properties for orders will be used again
val
- true - uses the old column model, false - recreates the column modelsetSelectSql( String)
public void refresh() throws java.sql.SQLException
java.sql.SQLException
public void refresh(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- The resultset that need to be loaded
java.sql.SQLException
public void refresh(java.util.Vector input) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- Vector of vectors which coontain the data
java.lang.Exception
public void refreshDataObject(java.util.Enumeration input, java.lang.String[] methodNames) throws java.lang.Exception
Important: The Data objects should be public class, not a default/protected class Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original Object when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- Enumeration which contains the data objectsmethodNames
- array of methodnames which should be used.
e.g if methods are getName(), getId(), then methodName = {"getName","getId"} if null is passed, then all the public methods which has no input parameters & which has a return type will be used
java.lang.Exception
public void refreshDataObject(java.util.Vector input, java.lang.String[] methodNames) throws java.lang.Exception
Important: The Data objects should be public class, not a default/protected class Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original Object when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- Vector which contains the data objectsmethodNames
- array of methodnames which should be used.
e.g if methods are getName(), getId(), then methodName = {"getName","getId"} if null is passed, then all the public methods which has no input parameters & which has a return type will be used
java.lang.Exception
public void refreshDataObject(java.util.Collection input, java.lang.String[] methodNames) throws java.lang.Exception
Important: The Data objects should be public class, not a default/protected class Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original Object when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- Collection which contains the data objectsmethodNames
- array of methodnames which should be used.
e.g if methods are getName(), getId(), then methodName = {"getName","getId"} if null is passed, then all the public methods which has no input parameters & which has a return type will be used
java.lang.Exception
public void refresh(java.lang.Object[][] input) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- two dimensional array
java.lang.Exception
public void refresh(java.net.URL url, java.util.Properties prop) throws java.lang.Exception
PLease set the correct proxy settings if you are within firewall HTTP: System.setProperty("http.proxyHost", proxyUrl); System.setProperty("http.proxyPort", proxyPort); HTTPS: System.setProperty("https.proxyHost", proxyUrl); System.setProperty("https.proxyPort", proxyPort); For using https url , 1) you need to have the "JavaTM Secure Socket Extension" in classpath This package comes with JDK 1.4. For all the older versions of JDK download the package from http://java.sun.com/products/jsse/ 2) set the provider & security as below System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
url
- the url which refers to the delimited file which you want to loadprop
- Properties for the data. Supported properties are delimiter, isfixedLengthColumns, firstRowHasColumnNames, columnLengthArray
delimiter - the delimiter character of the data e.g "," "|" isfixedLengthColumns - if the column data has fixed lengths. Possible value would be a not null object example "true" One of delimiter or isFixedLengthColumns should be present firstRowHasColumnNames (optional) - if the first row in the data has column names. Possible value would be a not null object example "true" columnLengthArray (required if isFixedLengthColumns is not null)- Array of Column lengths , if this data is fixed length column. e.g int[] arr = {25,100,10}; username (optional). if the url is protected by basic authentication, provide the username password (optional). if the url is protected by basic authentication, provide the password
java.lang.Exception
public void refresh(java.net.URL url, java.lang.String delimiter) throws java.lang.Exception
PLease set the correct proxy settings if you are within firewall HTTP: System.setProperty("http.proxyHost", proxyUrl); System.setProperty("http.proxyPort", proxyPort); HTTPS: System.setProperty("https.proxyHost", proxyUrl); System.setProperty("https.proxyPort", proxyPort); For using https url , 1) you need to have the "JavaTM Secure Socket Extension" in classpath This package comes with JDK 1.4. For all the older versions of JDK download the package from http://java.sun.com/products/jsse/ 2) set the provider & security as below System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
url
- the url which refers to the delimited file which you want to loaddelimiter
- - the delimiter character of the data e.g "," "|"
java.lang.Exception
public void refresh(java.io.File f, java.util.Properties prop) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
f
- File handle of the delimited fileprop
- Properties for the data. Supported properties are delimiter, isfixedLengthColumns, firstRowHasColumnNames, columnLengthArray
delimiter - the delimiter character of the data e.g "," "|" isfixedLengthColumns - if the column data has fixed lengths. Possible value would be a not null object example "true" One of delimiter or isFixedLengthColumns should be present firstRowHasColumnNames (optional) - if the first row in the data has column names. Possible value would be a not null object example "true" columnLengthArray (required if isFixedLengthColumns is not null)- Array of Column lengths , if this data is fixed length column. e.g int[] arr = {25,100,10};
java.lang.Exception
public void refresh(java.io.File f, java.lang.String delimiter) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
f
- File handle of the delimited filedelimiter
- - the delimiter character of the data e.g "," "|"
java.lang.Exception
public void refresh(java.io.InputStream input, java.util.Properties prop) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- Inputstream which has the delimited dataprop
- Properties for the data. Supported properties are delimiter, isfixedLengthColumns, firstRowHasColumnNames, columnLengthArray
delimiter - the delimiter character of the data e.g "," "|" isfixedLengthColumns - if the column data has fixed lengths. Possible value would be a not null object example "true" One of delimiter or isFixedLengthColumns should be present firstRowHasColumnNames (optional) - if the first row in the data has column names. Possible value would be a not null object example "true" columnLengthArray (required if isFixedLengthColumns is not null)- Array of Column lengths , if this data is fixed length column. e.g int[] arr = {25,100,10};
java.lang.Exception
public void refresh(java.io.InputStream input, java.lang.String delimiter) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- Inputstream which has the delimited datadelimiter
- - the delimiter character of the data e.g "," "|"
java.lang.Exception
public void refresh(java.io.BufferedReader in, java.util.Properties prop) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
in
- BufferedReader which has the delimited dataprop
- Properties for the data. Supported properties are delimiter, isfixedLengthColumns, firstRowHasColumnNames, columnLengthArray
delimiter - the delimiter character of the data e.g "," "|" isfixedLengthColumns - if the column data has fixed lengths. Possible value would be a not null object example "true" One of delimiter or isFixedLengthColumns should be present firstRowHasColumnNames (optional) - if the first row in the data has column names. Possible value would be a not null object example "true" columnLengthArray (required if isFixedLengthColumns is not null)- Array of Column lengths , if this data is fixed length column. e.g int[] arr = {25,100,10};
java.lang.Exception
public void refresh(java.io.BufferedReader input, java.lang.String delimiter) throws java.lang.Exception
Note: After loading this data into QuickTable, the changes made by editing the cells will not be saved to the original source when you use this refresh() method quicktable behaves as non database mode. So if you set any insert/update/delete statements or any database specific properties, they will not be executed
input
- BufferedReader which has the delimited datadelimiter
- - the delimiter character of the data e.g "," "|"
java.lang.Exception
public boolean isInsertingRow(int row)
public java.lang.Object[][] getDataArray()
public java.util.Vector getDataVector()
public void refreshSkin()
setSkin(Skin)
public void addTableCellListener(DBTableCellListener tc)
DBTableCellListener
public void removeTableCellListener(DBTableCellListener tc)
public void addDatabaseChangeListener(DatabaseChangeListener tc)
DatabaseChangeListener
public void removeDatabaseChangeListener(DatabaseChangeListener tc)
public void addDBTableErrorListener(DBTableErrorListener yourListener)
yourListener
- DBTableErrorListener
public void removeDBTableErrorListener(DBTableErrorListener yourListener)
public void addDBTableEventListener(DBTableEventListener yourListener)
yourListener
- DBTableEventListener
public void removeDBTableEventListener(DBTableEventListener yourListener)
public void createColumnModelFromQuery() throws java.sql.SQLException
java.sql.SQLException
public void close() throws java.sql.SQLException
java.sql.SQLException
public void update(int row, int col, java.lang.Object value) throws java.lang.Exception
java.lang.Exception
public void save()
public void enableExcelCopyPaste()
public void setCellPropertiesModel(CellPropertiesModel cellModel)
Color, Font, alignment of each cell in the table can be controlled using this. For complete information about using cell properties model refer to CellPropertiesModel class documentation
cellModel
- The cell properties model that needs to be set for this tableCellPropertiesModel
public CellPropertiesModel getCellPropertiesModel()
setCellPropertiesModel(CellPropertiesModel)
public java.awt.Point find(int r, int colIndex, java.lang.String findString1, java.util.Vector searchCol, boolean next)
This doesn't show any Find window where user can enter the text to be searched. you have to create your own window Otherwise you can use the Quicktable's find window. To show a quicktable's find Window use the method doFind() The main difference between this and the other find method is, this method cannot search in specific rows, other find method can search in specific set of rows Example to start searching from first row, and for searching 2nd and 4th columns only and starting the search from 4th column and searching the "quick" text backwards Vector columnVector = new Vector(); columnVector.addElement(new Integer(2)); columnVector.addElement(new Integer(4)); yourquicktable.find( 0, 2, "quick", columnVector, false); If you want to search only in specific set of rows use the other find method
r
- the starting row from which the search should be started. Row starts from 0,1,2..searchCol
- Vector of columns to be searched. example, if searching only 1st & 4th column, colVector.addElement(new Integer(1)); colVector.addElement(new Integer(4)); Important column starts from 1,2,3..colIndex
- the starting column within the searchCol vector, example if you want to start the searching from 3rd column, pass 2 because 4th column is the second index in colVector. Important the value for this argument cannot be greater than colVector sizefindString1
- the text that needs to be searchednext
- This determines the search direction, if this is true it searches forward, else backward
,
doFind()
,
find(int, int,String ,Vector, boolean , int[])
public java.awt.Point find(int r, int colIndex, java.lang.String findString1, java.util.Vector searchCol, boolean next, int[] row)
This doesn't show any Find window where user can enter the text to be searched. you have to create your own window Otherwise you can use the Quicktable's find window. To show a quicktable's find Window use the method doFind() The main difference between this and the other find method is, this method can search in specific set of rows whereas the other method can only do a general search Example Lets say user has selected a set of rows and you want to search within that rows only to start searching from first selected row, and for searching 2nd and 4th columns only and starting the search from 4th column and searching the "quick" text backwards Vector columnVector = new Vector(); columnVector.addElement(new Integer(2)); columnVector.addElement(new Integer(4)); yourquicktable.find( yourQuickTable.getTable().getSelectedRow(), 2, "quick", columnVector, false, yourQuickTable.getTable().getSelectedRows());
r
- the starting row from which the search should be started. Row starts from 0,1,2..searchCol
- Vector of columns to be searched. example, if searching only 1st & 4th column, colVector.addElement(new Integer(1)); colVector.addElement(new Integer(4)); Important column starts from 1,2,3..colIndex
- the starting column within the searchCol vector, example if you want to start the searching from 3rd column, pass 2 because 4th column is the second index in colVector. Important the value for this argument cannot be greater than colVector sizefindString1
- the text that needs to be searchednext
- This determines the search direction, if this is true it searches forward, else backwardrow
- int array of rows in which search should be done
doFind()
,
find(int, int,String ,Vector, boolean)
public java.awt.Point replace(int r, int colIndex, java.lang.String findString1, java.lang.String replaceString, java.util.Vector searchCol, boolean next)
This doesn't show any Find & Replace window where user can enter the text to be searched. you have to create your own window Otherwise you can use the Quicktable's find & replace window. To show a quicktable's find & replace Window use the method doFindAndReplace() The main difference between this and the other replace method is, this method cannot search in specific rows, other replace method can search in specific set of rows Example to start searching from first row, and for searching 2nd and 4th columns only and starting the search from 4th column and searching the "quick" text forwards and replacing the occurence with "table" Vector columnVector = new Vector(); columnVector.addElement(new Integer(2)); columnVector.addElement(new Integer(4)); yourquicktable.replace( 0, 2, "quick", "table", columnVector, true); Note : replace will replace only editable columns
r
- the starting row from which the search should be started. Row starts from 0,1,2..searchCol
- Vector of columns to be searched. example, if searching only 1st & 4th column, colVector.addElement(new Integer(1)); colVector.addElement(new Integer(4)); Important column starts from 1,2,3..colIndex
- the starting column within the searchCol vector, example if you want to start the searching from 3rd column, pass 2 because 4th column is the second index in colVector. Important the value for this argument cannot be greater than colVector sizefindString1
- the text that needs to be searchedreplaceString
- the text that needs to be replacednext
- This determines the search direction, if this is true it searches forward, else backward
doFindAndReplace()
,
replace(int, int,String ,String,Vector, boolean , int[])
public java.awt.Point replace(int r, int colIndex, java.lang.String findString1, java.lang.String replaceString, java.util.Vector searchCol, boolean next, int[] row)
This doesn't show any Find & Replace window where user can enter the text to be searched. you have to create your own window Otherwise you can use the Quicktable's find & replace window. To show a quicktable's find & replace Window use the method doFindAndReplace() The main difference between this and the other replace method is, this method can search in specific set of rows whereas the other can do only general search Example Lets say user has selected a set of rows and you want to search within that rows only to start searching from first row, and for searching 2nd and 4th columns only and starting the search from 4th column and searching the "quick" text forwards and replacing the occurence with "table" Vector columnVector = new Vector(); columnVector.addElement(new Integer(2)); columnVector.addElement(new Integer(4)); yourquicktable.replace( yourQuickTable.getTable().getSelectedRow(), 2, "quick", "table",columnVector, false, yourQuickTable.getTable().getSelectedRows()); Note : replace will replace only editable columns
r
- the starting row from which the search should be started. Row starts from 0,1,2..searchCol
- Vector of columns to be searched. example, if searching only 1st & 4th column, colVector.addElement(new Integer(1)); colVector.addElement(new Integer(4)); Important column starts from 1,2,3..colIndex
- the starting column within the searchCol vector, example if you want to start the searching from 3rd column, pass 2 because 4th column is the second index in colVector. Important the value for this argument cannot be greater than colVector sizefindString1
- the text that needs to be searchedreplaceString
- the text that needs to be replacednext
- This determines the search direction, if this is true it searches forward, else backward
doFindAndReplace()
,
replace(int, int,String ,String,Vector, boolean )
public java.awt.Point replaceAll(int r, int colIndex, java.lang.String findString1, java.lang.String replaceString, java.util.Vector searchCol)
The main difference between this and the other replaceAll method is, this method cannot search in specific rows, other replaceAll method can search in specific set of rows Example to start searching from first row, and for searching 2nd and 4th columns only and starting the search from 4th column and searching the "quick" text forwards and replacing the occurence with "table" Vector columnVector = new Vector(); columnVector.addElement(new Integer(2)); columnVector.addElement(new Integer(4)); yourquicktable.replaceAll( 0, 2, "quick", "table", columnVector);
r
- the starting row from which the search should be started. Row starts from 0,1,2..searchCol
- Vector of columns to be searched. example, if searching only 1st & 4th column, colVector.addElement(new Integer(1)); colVector.addElement(new Integer(4)); Important column starts from 1,2,3..colIndex
- the starting column within the searchCol vector, example if you want to start the searching from 3rd column, pass 2 because 4th column is the second index in colVector. Important the value for this argument cannot be greater than colVector sizefindString1
- the text that needs to be searchedreplaceString
- the text that needs to be replaced
replaceAll(int, int,String ,String,Vector, int[])
public java.awt.Point replaceAll(int r, int colIndex, java.lang.String findString1, java.lang.String replaceString, java.util.Vector searchCol, int[] row)
The main difference between this and the other replaceAll method is, this method can search in specific rows whereas the other cannot Example Lets say user has selected a set of rows and you want to search within that rows only to start searching from first row, and for searching 2nd and 4th columns only and starting the search from 4th column and searching the "quick" text forwards and replacing the occurence with "table" Vector columnVector = new Vector(); columnVector.addElement(new Integer(2)); columnVector.addElement(new Integer(4)); yourquicktable.replace( yourQuickTable.getTable().getSelectedRow(), 2, "quick", "table",columnVector, yourQuickTable.getTable().getSelectedRows());
r
- the starting row from which the search should be started. Row starts from 0,1,2..searchCol
- Vector of columns to be searched. example, if searching only 1st & 4th column, colVector.addElement(new Integer(1)); colVector.addElement(new Integer(4)); Important column starts from 1,2,3..colIndex
- the starting column within the searchCol vector, example if you want to start the searching from 3rd column, pass 2 because 4th column is the second index in colVector. Important the value for this argument cannot be greater than colVector sizefindString1
- the text that needs to be searchedreplaceString
- the text that needs to be replaced
replaceAll(int, int,String ,String,Vector)
public void doFind()
find(int, int,String ,Vector, boolean)
,
find(int, int,String ,Vector, boolean, int[])
public void doFindAndReplace()
replace(int, int,String ,String,Vector, boolean)
,
replace(int, int,String ,String,Vector, boolean, int[])
public void setSkin(Skin skin)
Skins are used to apply style for your quickTable. Advantages of skins are 1) Business logic and presentation separation 2) You can change the style without changing the code 3) You can get good skins from professional designers To know more about how to create your own skin, refer to Skin interface documentation
skin
- the skin that need to be set to tableSkin
public Skin getSkin()
public void setCellComponent(Column c, int cellType, java.util.Hashtable cellValueToDisplayHash)
Currently QuickTable supports the following components Icon, CheckBox, RadioButton, ComboBox. Note: If you need Textarea editor ( multiple line editing) , instead of textfield editor (single line editing) for cell, use LONGVARCHAR as column type e.g dbTable.getColumn(1).setType(java.sql.Types.LONGVARCHAR) Setting Icon component Icon component displays the icon and when the user tries to edit the icon, it displays a list of icons in a combobox, user can select one of the icon from combo box set the celltype argument as Column.IMAGE_CELL set the cellValueToDisplayHash to hashtable which contains a mapping of actual cell data to the icon that need to be displayed For example, lets say the database contains "A" for employee alive, "D" for employee dead and "L" for employee on Leave and you have three gif files to represent these states alive.gif, dead.gif, leave.gif Hashtable imageHash = new Hashtable(); imageHash.put("A",new ImageIcon(this.getClass().getResource("images/alive.gif"))); imageHash.put("D",new ImageIcon(this.getClass().getResource("images/dead.gif"))); imageHash.put("L",new ImageIcon(this.getClass().getResource("images/leave.gif"))); //Note: make sure you have the images directory in classpath yourQuickTable.setCellComponent(yourQuickTable.getColumn(1), Column.IMAGE_CELL , imageHash) Note: For IMAGE_CELL, an empty row is added to combo box editor, so that users can use this to clear the data in the cell. If you don't need this empty row, use the other method see api for: setCellComponent(Column , int , Hashtable, boolean ) setting Checkbox component checkbox component displayes a checkbox, user will be able to edit the check box by checking or unchecking set the celltype argument as Column.CHECKBOX_CELL set the cellValueToDisplayHash to hashtable which contains a mapping of actual cell data to the checkbox selection state For example, lets say the database contains "A" for employee alive, "D" for employee dead and if you want to set the checkbox selected when "A" and unselected when "D" Hashtable checkHash = new Hashtable(); checkHash.put("A",new Boolean(true)); checkHash.put("D",new Boolean(false)); yourQuickTable.setCellComponent(yourQuickTable.getColumn(1), Column.CHECKBOX_CELL , checkHash) setting radiobutton component radiobutton component displayes a radiobutton, user will be able to edit the radiobutton by selecting or deselecting set the celltype argument as Column.RADIOBUTTON_CELL set the cellValueToDisplayHash to hashtable which contains a mapping of actual cell data to the checkbox selection state For example, lets say the database contains "A" for employee alive, "D" for employee dead and if you want to set the radiobutton selected when "A" and unselected when "D" Hashtable radioHash = new Hashtable(); radioHash.put("A",new Boolean(true)); radioHash.put("D",new Boolean(false)); yourQuickTable.setCellComponent(yourQuickTable.getColumn(1), Column.RADIOBUTTON_CELL , radioHash) For COMBOBOX_CELL comboBox editor combox editor displayes a list of values in a combo box where user can select a value For example, lets say the database contains "A" for employee alive, "D" for employee dead and if you want to show "Alive" instead of "A" in the combo box list and "Dead" instead of "D" Hashtable comboHash = new Hashtable(); comboHash.put("A","Alive"); comboHash.put("D","Dead"); yourQuickTable.setCellComponent(yourQuickTable.getColumn(1), Column.COMBOBOX_CELL , comboHash); Note: For COMBOBOX_CELL, an empty row is added to combo box editor, so that users can use this to clear the data in the cell. If you don't need this empty row, use the other method see api for: setCellComponent(Column , int , Hashtable, boolean ) In the above case the database values "A", "D" are diffrenet from the combo box listed values "Alive","Dead". But in some cases database values & combo box listed values are same in that case, use as below Example class MyCell implements CellComponent { JCombobox myCombo = new JCombobox(); MyCell() { myCombo.addItem("Alive"); myCombo.addItem("Dead"); myCombo.addItem("Leave"); } public void setValue(Object value) { comboBox.setSelectedItem(o); //handle the case if null is passed } public Object getValue() { return comboBox.getSelectedItem(); //return "" if nothing is selected } public JComponent getComponent() { return mycombo; } } yourQuickTable.getColumn(1).setUserCellEditor(new MyCell()); To create a combo box editor which contains the listed items from a Sql query use yourQuickTable.getColumn(1).setBoundSql("select distinct status from employee:);
c
- Column to which the Cell component should be assignedcellType
- Any one of Column.IMAGE_CELL or Column.CHECKBOX_CELL or Column.RADIOBUTTON_CELL or COMBOBOX_CELLcellValueToDisplayHash
- hashtable which contains a mapping of actual cell data to the display dataColumn.setUserCellEditor(CellComponent)
,
setCellComponent(Column , int , Hashtable, boolean )
public void setCellComponent(Column c, int cellType, java.util.Hashtable cellValueToDisplayHash, boolean addClearOption)
c
- Column to which the Cell component should be assignedcellType
- Any one of Column.IMAGE_CELL or Column.CHECKBOX_CELL or Column.RADIOBUTTON_CELL or COMBOBOX_CELLcellValueToDisplayHash
- hashtable which contains a mapping of actual cell data to the display dataaddClearOption
- If true, adds an empty cell to combo box editor. This will be helpful to make the cell empty.setCellComponent(Column, int , Hashtable)
public void setCellComponent(Column c, int cellType, java.util.Hashtable cellValueToDisplayHash, java.lang.Object[] keysSortOrder, boolean addClearOption)
Object[] keysSortOrder = new Object[2]; keysSortOrder[0]="D"; keysSortOrder[1]="A"; Hashtable comboHash = new Hashtable(); comboHash.put(keysSortOrder[1],"Alive"); comboHash.put(keysSortOrder[0],"Dead"); yourQuickTable.setCellComponent(yourQuickTable.getColumn(1), Column.COMBOBOX_CELL , comboHash, keysSortOrder, false); This will display the combox items in order Dead, Alive.
c
- Column to which the Cell component should be assignedcellType
- Any one of Column.IMAGE_CELL or Column.CHECKBOX_CELL or Column.RADIOBUTTON_CELL or COMBOBOX_CELLcellValueToDisplayHash
- hashtable which contains a mapping of actual cell data to the display datakeysSortOrder
- An object array of keys which are present in cellValueToDisplayHash.addClearOption
- If true, adds an empty cell to combo box editor. This will be helpful to make the cell empty.setCellComponent(Column, int , Hashtable)
public void clearAllDeleteSql()
addDeleteSql(String, String)
public void clearAllInsertSql()
addInsertSql(String, String)
public void clearAllUpdateSql()
addUpdateSql(String, String)
public void print()
print(int[])
public void print(PrintProperties prop)
print(int[],PrintProperties)
public void print(int pageWidth, int pageHeight)
You can use this method to print in Landscape mode Landscape mode or portriat mode is decided by the pagewidth & pageHeight For exampele to print in landscape mode for A4 size yourQuicktable.print(792,612); to print in portriat mode for A4 size yourQuicktable.print(612,792); If you want to print only specific pages use print(int[], int, int)
pageWidth
- actual width of paper, in 1/72nds of an inchpageHeight
- actual height of paper, in 1/72nds of an inchprint(int[], int, int)
public void print(int[] pages)
pages
- int array of pages that should be printedprint()
public void print(int[] pages, PrintProperties prop)
pages
- int array of pages that should be printedprint(PrintProperties)
public void print(int[] pages, int pageWidth, int pageHeight)
You can use this method to print in Landscape mode Landscape mode or portriat mode is decided by the pagewidth & pageHeight For exampele to print in landscape mode for A4 size yourQuicktable.print(792,612); to print in portriat mode for A4 size yourQuicktable.print(612,792); If you want to print all pages, use print(int, int)
pages
- int array of pages that should be printedpageWidth
- actual width of paperpageHeight
- actual height of paperprint(int, int)
public void copyToClipboard(int[] row)
row
- the rows which need to be copied, if null is passed all the selected rows will be copiedpublic void pasteFromClipboard()
public java.awt.print.Printable getPrintable(PrintProperties prop)
//get the printer java.awt.print.PrinterJob printJob = java.awt.print.PrinterJob.getPrinterJob(); //get the printable object from dbtable printJob.setPrintable(dbTable.getPrintable(new PrintProperties())); //show the print dialog, if the user presses print in the dialog, then print //if you do not want to show dialog, comment the next line and directly call print() if( printJob.printDialog() ) printJob.print();In JDK 1.4 or above
//get the printable object from dbtable java.awt.print.Printable print = dbTable.getPrintable(new PrintProperties()); //set print type javax.print.DocFlavor flavor = javax.print.DocFlavor.SERVICE_FORMATTED.PRINTABLE; javax.print.SimpleDoc doc = new javax.print.SimpleDoc(print, flavor, null); //get printer PrintService service = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob job = service.createPrintJob(); //print job.print(doc, null);For more info refer http://javaalmanac.com/egs/javax.print/pkg.html
public void printPreview()
public void printPreview(int pageWidth, int pageHeight)
Landscape mode or portriat mode is decided by the pagewidth & pageHeight For exampele to print preview in landscape mode for A4 size yourQuicktable.printPreview(792,612); to print preview in portriat mode for A4 size yourQuicktable.printPreview(612,792);
pageWidth
- actual width of paper, in 1/72nds of an inchpageHeight
- actual height of paper,in 1/72nds of an inchpublic void printPreview(PrintProperties prop)
public PreviewPanel getPrintPreviewCanvas()
public PreviewPanel getPrintPreviewCanvas(int pageWidth, int pageHeight)
Landscape mode or portriat mode is decided by the pagewidth & pageHeight For exampele to create print preview in landscape mode for A4 size yourQuicktable.getPrintPreviewCanvas(792,612); to create print preview in portriat mode for A4 size yourQuicktable.getPrintPreviewCanvas(612,792);
pageWidth
- actual width of paperpageHeight
- actual height of paperpublic PreviewPanel getPrintPreviewCanvas(PrintProperties prop)
public void setEditable(boolean val)
If you don't want the users to edit the data in any of the cells in the table you can call yourQuickTable.setEditable(false); This methods helps to set the editable property of the whole table. If you want to make some columns editable and some columns not editable you can call setReadOnly() method for that specific column Note: This method overrides the column setReadOnly() property. If you want to make some columns editable and others non editable, then you have to call setEditable(true) first and then set the column which are non editable as setReadonly(true). By default quicktable is started with setEditable(true) If you need to control the editable property based on cell by cell, then you need to use the CellPropertiesModel class and override the isCellEditable() method.
val
- true - to make table editable, false to make the table non editableColumn.setReadOnly(boolean)
public Column getColumnByDatabaseName(java.lang.String colName)
colName
- database column namepublic Column getColumnByHeaderName(java.lang.String colName)
colName
- column header namepublic void sortByColumn(int column, boolean ascending)
column
- sort columnascending
- sort modesortByColumns(Vector,boolean)
public java.util.Vector getSortColumns()
sortByColumns(Vector,boolean)
public boolean isSortAscending()
public void sortByColumns(java.util.Vector columnVector, boolean ascending)
columnVector
- columnVector which contains Integer objects corresponding to the columns that should be sortedascending
- sort modesortByColumn(int, boolean)
public void filter(Filter filter)
Filter
public void filter(int column, int criteria, java.lang.Object key)
column
- The column number starts from 0,1,2,3criteria
- One of EQUAL or GREATER or LESSkey
- the object to which the cell data will be comparedFilter
public static int compareObject(java.lang.Object o1, java.lang.Object o2)
Filter
public java.lang.Object getRowObject(int row)
row
- the row for which you need the data objectrefreshDataObject(Vector, String[])
,
refreshDataObject(Enumeration, String[])
public void setComparator(Comparator comp)
public void setSorter(Sorter sorter)
public void clearAllSettings()
public java.lang.String getVersion()
public void setDBTableLocale(java.util.Locale currentLocale, java.awt.Font localeFont)
For example to set the Locale to French language, the country of Canada, and the UNIX platform. yourQuickTable.setDBTableLocale(new Locale("fr", "CA", "UNIX")); You should also provide a properties file which has the text mappings for that locale. In the above case the properties file would have the name QuickTable_fr_CA_UNIX.properties This properties file should be present in the classpath. Following is the contents of the default properties file Record=Record FirstRow=First row PreviousRow=Previous row NextRow=Next row LastRow=Last row AddRow=Add row DeleteRow=Delete row of=of UnableToDelete=Unable to delete! FinishedSearching=Finished Searching ReplaceFormat=Replace this occurrence of {0} FinishedReplacing=Finished Replacing TotalReplacements={0,number,integer} replacements! TextToFind=Text to find FindNext=Find Next FindPrevious=Find Previous ReplaceAll=Replace All Close=Close FromSelectedRow=From selected row ReplaceWith=Replace With Print=Print Next=Next Previous=Previous January=January February=February March=March April=April May=May June=June July=July August=August September=September October=October November=November December=December Sunday=S Monday=M Tuesday=T Wednesday=W Thursday=T Friday=F Saturday=S Ok=Ok Cancel=Cancel Clear=Clear DriverNotFound=Unable to find the Database Driver! DatabaseError=Database error! EmptyCell=This cell can't be empty! InsertError=Unable to Insert! UpdateError=Unable to Update! SelectDate=Select Date ReplaceNext=Replace Next ReplacePrevious=Replace Previous Copy these mapping entries to your locale properties file and then provide the translations for your language For example of=de Please refer to http://java.sun.com/docs/books/tutorial/i18n/index.html for more information. QuickTable download file (zip/tar) has the properties file for the following languages. JAPANESE(QuickTable_ja.properties), FRENCH(QuickTable_fr.properties), GERMAN(QuickTable_de.properties), SPANISH(QuickTable_es.properties),ITALIAN (QuickTable_it.properties), PORTUGUESE(QuickTable_pt.properties), CHINESE(QuickTable_zh.properties), RUSSIAN(QuickTable_ru.properties),KOREAN(QuickTable_ko.properties). These files can be found in the "lib" directory For languages with non latin characters like Chinese, setting locale alone is not enough. You also have to set the font. Sometimes, the fon't you mention may not be available at runtime. In that case, use the other method setDBTableLocale(Locale, String ) and pass a sample text of that language, quickTable can find the font which can display that text in runtime.
setDBTableLocale(Locale, String )
,
setDBTableLocale(Locale)
public void setDBTableLocale(java.util.Locale currentLocale)
You need to add your language specific quicktable properties file to classpath. For more information about this properties file, refer to setDBTableLocale(Locale, Font ). QuickTable download file (zip/tar) has the properties file for the following languages. JAPANESE(QuickTable_ja.properties), FRENCH(QuickTable_fr.properties), GERMAN(QuickTable_de.properties), SPANISH(QuickTable_es.properties),ITALIAN (QuickTable_it.properties), PORTUGUESE(QuickTable_pt.properties), CHINESE(QuickTable_zh.properties), RUSSIAN(QuickTable_ru.properties),KOREAN(QuickTable_ko.properties). These files can be found in the "lib" directory For languages with non latin characters like Chinese, setting locale alone is not enough. You also have to set the font. Use setDBTableLocale(Locale, Font ) to set the font.
setDBTableLocale(Locale, Font )
public void setDBTableLocale(java.util.Locale currentLocale, java.lang.String localeUnicodeText)
You need to add your language specific quicktable properties file to classpath. For more information about this properties file, refer to setDBTableLocale(Locale, Font ). QuickTable download file (zip/tar) has the properties file for the following languages. JAPANESE(QuickTable_ja.properties), FRENCH(QuickTable_fr.properties), GERMAN(QuickTable_de.properties), SPANISH(QuickTable_es.properties),ITALIAN (QuickTable_it.properties), PORTUGUESE(QuickTable_pt.properties), CHINESE(QuickTable_zh.properties), RUSSIAN(QuickTable_ru.properties),KOREAN(QuickTable_ko.properties). These files can be found in the "lib" directory For languages with non latin characters like Chinese, setting locale alone is not enough. You also have to set the font. Sometimes, the fon't you mention may not be available at runtime. If you give a sample text quickTable can find the font which can display that text in runtime. Note: There may be a performance impact with this method because this operation has to go through all the installed fonts. If it finds a match within first few fonts,this method will return quickly. If it goes through all fonts this method will take some time. e.g setDBTableLocale(Locale.CHINESE,"\u65E0\u6CD5\u5220\u9664");
setDBTableLocale(Locale, Font )
public java.awt.Font findFont(java.lang.String sampleText)
Since you may not be sure what fonts are available at runtime, you can use this method to find the font in runtime, which can display your language specific text e.g findFont("\u65E0\u6CD5\u5220\u9664"); Note: There may be a performance impact with this method because this operation has to go through all the installed fonts. If it finds a match within first few fonts,this method will return quickly. If it goes through all fonts this method will take some time.
setDBTableLocale(Locale, Font )
public void setFixedColumns(int[] cols)
This will make the fixed columns not scrollable, while other columns can be scrollable horizontally. Note: column starts from 1,2 Fixed Columns implementation: JTable doesn't support fixed columns, so fixed columns are simulated by adding another JTable in the left side of the JTable, which will hold fixed columns and in the main table these fixed columns will be hidden. So when you try to navigate rows/cells using keyboards you may not see the right behaviour. Since the fixed columns are simulated, you cannot sort or apply quickTable specific cell/column properties like color/font/alignment/renederer/combobox/radio/image/check box editor etc. You will get the handle to the fixed JTable by calling getFixedTable(), you can access the columnmodel & tablemodel of this fixed JTable and you can use that to customize the fixed columns. Any DBTable cell/column settings which you apply to the main table will not be applied to the fixed columns. In the main table, the fixed columns will be hidden, if necessary, you can make them visible by calling dbTable.getColumn(1).setVisible(true) on those columns. Once you make them visible, sorting ,cell properties cell editors can be applied for those columns. There is no limit to how many columns you can add to fixed columns, but the width of quicktable should be greater than fixed column's width, then only you can view the horizontal scroll bar for non fixed columns & the non fixed columns After setting the fixed columns, if you want to hide it, call setFixedColumns(null)
public javax.swing.JTable getFixedTable()
public void setMaximumRowCount(int row)
row
- the maximum row countpublic int getMaximumRowCount()
public void setDatabaseUpdateMode(int mode)
mode
- Either UPDATE_DATABASE_ON_CELL_EXIT or UPDATE_DATABASE_ON_ROW_EXIT, the default is UPDATE_DATABASE_ON_ROW_EXITpublic int getDatabaseUpdateMode()
public javax.swing.table.JTableHeader getTableHeader()
public int getColumnCount()
getRowCount()
public boolean editCellAt(int row, int column)
row
- the row to be editedcolumn
- the column to be edited
java.lang.IllegalArgumentException
- If row or column
are not in the valid rangepublic int getEditingColumn()
public int getEditingRow()
public int getRowCount()
getColumnCount()
public int getSelectedColumn()
public int getSelectedColumnCount()
public int[] getSelectedColumns()
getSelectedColumn()
public int getSelectedRow()
public int getSelectedRowCount()
public int[] getSelectedRows()
getSelectedRow()
public java.lang.Object getValueAt(int row, int column)
Source: Copied from JTable for convenience
row
- the row whose value is to be looked upcolumn
- the column whose value is to be looked up
public boolean isRowSelected(int row)
java.lang.IllegalArgumentException
- if row is not in the
valid rangepublic void moveColumn(int column, int targetColumn)
column
- the index of column to be movedtargetColumn
- the new index of the columnpublic void removeColumnSelectionInterval(int index0, int index1)
index0
- one end of the interval.index1
- other end of the intervalpublic void removeRowSelectionInterval(int index0, int index1)
index0
- one end of the interval.index1
- other end of the intervalpublic void selectAll()
public void setRowSelectionInterval(int index0, int index1)
index0
- one end of the interval.index1
- other end of the intervalpublic void setValueAt(java.lang.Object aValue, int row, int column)
aValue
- the new valuerow
- the row whose value is to be changedcolumn
- the column whose value is to be changedgetValueAt(int, int)
public void clearSelection()
public void addColumnSelectionInterval(int index0, int index1)
index0
- one end of the interval.index1
- other end of the intervalpublic void addRowSelectionInterval(int index0, int index1)
index0
- one end of the interval.index1
- other end of the intervalpublic void fireTableCellUpdated(int row, int column)
public void fireTableDataChanged()
public void selectCell(int rowOfCellToBeSelected, int columnOfCellToBeSelected)
public void selectCell(int rowOfCellToBeSelected, int columnOfCellToBeSelected, boolean focus)
public void selectFirstVisibleColumnCell(int row, boolean focus)
public void loadAllRows()
public void removeColumnHeader()
public void addFocusListener(java.awt.event.FocusListener l)
public void addKeyListener(java.awt.event.KeyListener l)
public void addMouseListener(java.awt.event.MouseListener l)
public void removeFocusListener(java.awt.event.FocusListener l)
public void removeKeyListener(java.awt.event.KeyListener l)
public void removeMouseListener(java.awt.event.MouseListener l)
public void removeNotify()
public void cleanup()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |