|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.TableColumn quick.dbtable.Column
This class defines the properties of a column in DBTable. See Column FAQ
Field Summary | |
static java.lang.String |
BOUND_SQL_PROPERTY
|
static int |
CHECKBOX_CELL
|
static java.lang.String |
COLUMN_NAME_PROPERTY
|
static int |
COMBOBOX_CELL
|
static java.lang.String |
DATA_MAP_PROPERTY
|
static int |
DATE_CELL
|
static java.lang.String |
DATE_FORMAT_PROPERTY
|
static int |
DEFAULT_CELL
|
static java.lang.String |
DOCUMENT_PROPERTY
|
static java.lang.String |
EDITOR_PROPERTY
|
static int |
IMAGE_CELL
|
static java.lang.String |
LENGTH_PROPERTY
|
static java.lang.String |
NULLABLE_PROPERTY
|
static java.lang.String |
PRECISION_PROPERTY
|
static int |
RADIOBUTTON_CELL
|
static java.lang.String |
READ_ONLY_PROPERTY
|
static java.lang.String |
RENDERER_PROPERTY
|
static java.lang.String |
SCALE_PROPERTY
|
static java.lang.String |
SIGNED_PROPERTY
|
static int |
TEXTAREA_CELL
|
static java.lang.String |
TYPE_PROPERTY
|
static int |
USER_CELL
|
static java.lang.String |
VISIBLE_PROPERTY
|
Fields inherited from class javax.swing.table.TableColumn |
CELL_RENDERER_PROPERTY, COLUMN_WIDTH_PROPERTY, HEADER_RENDERER_PROPERTY, HEADER_VALUE_PROPERTY |
Constructor Summary | |
Column()
Deprecated. This constructor is deprecated because lot of users don't change the model index id to value other than 0 which creates problems later on. use Column(int columnIndex) instead. |
|
Column(int columnIndex)
This calls the TableColumn's constructor This creates a default width of 75, a null renderer and a null editor for this column columnIndex starts from 1 to number of columns (note column index doesn't start from 0) If columnIndex is not properly assigned, this will create problems later on. |
|
Column(int columnIndex,
int width)
This calls the TableColumn's constructor This creates a column of the specified width , a null renderer and a null editor |
|
Column(int columnIndex,
int width,
javax.swing.table.TableCellRenderer cellRenderer,
javax.swing.table.TableCellEditor cellEditor)
Deprecated. Quicktable uses CellComponent instead of TableCellRenderer & cellEditor, use setUserCellEditor/setUserCellRenderer methods instead. |
|
Column(int columnIndex,
java.lang.String columnHeaderName)
This calls the TableColumn's constructor This creates a default width of 75, a null renderer and a null editor for this column and sets the column header Name to this name |
Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
java.lang.String |
getBoundSql()
returns the bound sql of this column |
java.lang.String |
getColumnName()
returns the actual database column name |
DataMap |
getDataMap()
returns the dataMap property of the column. |
java.lang.String |
getDateFormat()
returns the date format of this column |
javax.swing.text.Document |
getDocument()
returns the date format of this column |
int |
getLength()
returns the length of the column, for non numeric |
java.lang.String |
getMethodName()
gets the method name which is used by this column. |
boolean |
getNullable()
returns the nullable property of this column |
int |
getPrecision()
returns the precision of the column , if this is of type numeric , float, or double |
boolean |
getReadOnly()
returns whether the column is readonly |
ResultSetMap |
getResultSetMap()
gets the ResultSetMap for this column. |
int |
getScale()
returns the scale of the column , if this is of type numeric , float, or double |
boolean |
getSigned()
returns the signed property of the column |
int |
getType()
returns the type of the database column, refer to java.sql.Types for the available types |
CellComponent |
getUserCellEditor()
Gets the user Cell Editor |
CellComponent |
getUserCellRenderer()
gets the user Cell Renderer |
boolean |
isVisible()
returns whether the column is currently visible or not |
void |
refreshBoundCombo()
Refresh the bound combo in this column |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
setBoundSql(java.lang.String sql)
sets the bound column sql |
void |
setColumnName(java.lang.String val)
Sets the actual database column name |
void |
setDataMap(DataMap val)
sets the dataMap property of the column. |
void |
setDateFormat(java.lang.String dateFormat)
If this is a date type column and if you want to display the date in a specific format, you can use this method. |
void |
setDocument(javax.swing.text.Document document)
This is used to set the document, if this column has a textfield cell editor Masking & input validation can be done using document |
void |
setLength(int val)
Sets the length of the column ( for non numeric columns only). |
void |
setMethodName(java.lang.String methodName)
sets the method name which is used by this column. |
void |
setNullable(boolean val)
sets the nullable property of this column setting this false, will prevent the cell of this column being emptied out. |
void |
setPrecision(int val)
Sets the precision of the column , if this is of type numeric , float, or double |
void |
setPreferredWidth(int width)
|
void |
setReadOnly(boolean val)
Sets the read only property of the column |
void |
setResultSetMap(ResultSetMap val)
Sets the ResultSetMap for this column. |
void |
setScale(int val)
Sets the scale of the column , if this is of type numeric , float, or double |
void |
setSigned(boolean val)
Sets the signed property of the column |
void |
setType(int val)
Sets the type of the database column, refer to java.sql.Types for the available types use setType(Types.LONGVARCHAR) = If you need Textarea editor ( multiple line editing) , instead of textfield editor (single line editing) , use LONGVARCHAR even if the database type is VARCHAR |
void |
setUserCellEditor(CellComponent cc)
Sets the user Cell Editor |
void |
setUserCellRenderer(CellComponent cc)
Sets the user Cell Renderer |
void |
setVisible(boolean val)
To hide/show this column When the column is invisible, this invisible column's data is still accessible. |
void |
setWidth(int width)
|
Methods inherited from class javax.swing.table.TableColumn |
disableResizedPosting, enableResizedPosting, getCellEditor, getCellRenderer, getHeaderRenderer, getHeaderValue, getIdentifier, getMaxWidth, getMinWidth, getModelIndex, getPreferredWidth, getPropertyChangeListeners, getResizable, getWidth, setCellEditor, setCellRenderer, setHeaderRenderer, setHeaderValue, setIdentifier, setMaxWidth, setMinWidth, setModelIndex, setResizable, sizeWidthToFit |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String READ_ONLY_PROPERTY
public static final java.lang.String TYPE_PROPERTY
public static final java.lang.String COLUMN_NAME_PROPERTY
public static final java.lang.String SCALE_PROPERTY
public static final java.lang.String PRECISION_PROPERTY
public static final java.lang.String LENGTH_PROPERTY
public static final java.lang.String NULLABLE_PROPERTY
public static final java.lang.String SIGNED_PROPERTY
public static final java.lang.String BOUND_SQL_PROPERTY
public static final java.lang.String DATE_FORMAT_PROPERTY
public static final java.lang.String DOCUMENT_PROPERTY
public static final java.lang.String DATA_MAP_PROPERTY
public static final java.lang.String EDITOR_PROPERTY
public static final java.lang.String RENDERER_PROPERTY
public static final java.lang.String VISIBLE_PROPERTY
public static final int IMAGE_CELL
public static final int CHECKBOX_CELL
public static final int RADIOBUTTON_CELL
public static final int DEFAULT_CELL
public static final int DATE_CELL
public static final int COMBOBOX_CELL
public static final int TEXTAREA_CELL
public static final int USER_CELL
Constructor Detail |
public Column()
public Column(int columnIndex)
public Column(int columnIndex, int width)
public Column(int columnIndex, java.lang.String columnHeaderName)
public Column(int columnIndex, int width, javax.swing.table.TableCellRenderer cellRenderer, javax.swing.table.TableCellEditor cellEditor)
Method Detail |
public boolean getReadOnly()
public void setReadOnly(boolean val)
public DataMap getDataMap()
DataMap
public void setDataMap(DataMap val)
DataMap
public int getType()
public void setType(int val)
public java.lang.String getColumnName()
public void setColumnName(java.lang.String val)
This won't set the column name in the Jtable, to set the columnname in Jtable use the setHeaderValue method, for example yourColumn.setHeaderValue("Emp\nId"); Note: Multiline column headers are not supported in Mac OS. So in Mac OS, setHeaderValue() with a header with newline will show in one line.
public int getScale()
public void setScale(int val)
public int getPrecision()
public void setPrecision(int val)
public int getLength()
public void setLength(int val)
public boolean getNullable()
public void setNullable(boolean val)
public boolean getSigned()
public void setSigned(boolean val)
public java.lang.String getBoundSql()
public void setBoundSql(java.lang.String sql)
If this column is bound with a column in another table, then a combo box celleditor will be used for this column & this sql will be used to fill that combobox. Case 1: (Using value bound sql) Lets say the data which you are trying to display is employee --------- 1, emp_nam1, dept1 1, emp_nam2, dept2 1, emp_nam3, dept1 For the third column, you want the users to enter values dep1, dep2 only and you have a department table which has these allowed data departmnet ---------- no, dept 1, dept1 2, dept2 Then you can set the boundsql to "select dept from department" When the user tries to edit any cell in this column, it will show a combobox with values dept1,dept2, so the user can select only these values Case 2: (Using key/value bound sql) Following is a employee database table employee --------- emp_no, name, dept_no 1, emp_nam1, 1 1, emp_nam2, 2 1, emp_nam3, 1 when you display in quicktable you want to display dept name, instead of dept no 1, emp_nam1, dept1 1, emp_nam2, dept2 1, emp_nam3, dept1 and when user modified the dept, you actually want to update the dept_no, instead of dept name, then you can set the boundsql to "select dept_no, dept_name from department" When the user tries to edit any cell in this column, it will show a combobox with values dept1,dept2, so the user can select only these values. Once the user select a new departmnet, the actual dept_no will be updated in database
public void setDateFormat(java.lang.String dateFormat)
Examples Using the US Locale: Format Pattern Result -------------- ------- "yyyy.MM.dd G 'at' hh:mm:ss z" ->> 1996.07.10 AD at 15:08:56 PDT "EEE, MMM d, ''yy" ->> Wed, July 10, '96 "h:mm a" ->> 12:08 PM "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time "K:mm a, z" ->> 0:00 PM, PST "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM Example : myColumn.setDateFormat("EEE, MMM d, ''yy");
public java.lang.String getDateFormat()
public void setDocument(javax.swing.text.Document document)
public javax.swing.text.Document getDocument()
public void refreshBoundCombo()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedpublic void setVisible(boolean val)
public boolean isVisible()
public void setPreferredWidth(int width)
public void setWidth(int width)
public void setUserCellEditor(CellComponent cc)
public CellComponent getUserCellEditor()
public void setUserCellRenderer(CellComponent cc)
public CellComponent getUserCellRenderer()
public java.lang.String getMethodName()
public void setMethodName(java.lang.String methodName)
public void setResultSetMap(ResultSetMap val)
QuickTable uses getObject() , setObject method in resultset to read the data. But in some special cases you have to handle it differently. This class helps to do that. Example : If the data type in database is nvarchar, then you have to use getString() ( getObject() doesn't work) If data is stored as stream in database, instead of using getObject() , you have to use getBinaryStream() Sample implementation public class StreamResultSetMap extends ResultSetMap { public Object getObject(ResultSet rs, int column) throws SQLException { InputStream in = rs.getBinaryStream(column); String value = createStringFromStream(in); return value; } public void setObject(PreparedStatement pStmt, int column, Object value) throws SQLException { rs.setBinaryStream(column,getStreamFromString(value), getLengthOfStreamFromValue(value)); } } //for a new select sql for dbtable, setResultSetMap should be called after createColumnModelFromQuery() and //before calling refresh() dbtable.createColumnModelFromQuery(); yourColumn.setResultSetMap( new StreamResultSetMap() ); dbtable.refresh();
ResultSetMap
public ResultSetMap getResultSetMap()
setResultSetMap(ResultSetMap)
,
ResultSetMap
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |