borland Packages  Class Hierarchy  dbswing Package 

JdbTable component

java.lang.Object
   +----java.awt.Component
           +----java.awt.Container
                   +----javax.swing.JComponent
                           +----javax.swing.JTable
                                   +----com.borland.dbswing.JdbTable

About the JdbTable component

Variables  Constructors  Properties  Methods  Event Listeners

Implements AccessListener, DataChangeListener, DataSetAware, NavigationListener, ActionListener, KeyListener, MouseListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, TableColumnModelListener, TableModelListener, Scrollable

Note: This is a feature of JBuilder Professional and Enterprise.

JdbTable is a data-aware extension of JTable that adds support for these features:

As with other dbSwing controls, JdbTable allows you to set display properties on the component, but when properties are not set, values are inherited from the Columns of the DataSet to which the table is bound.

Working with tables

JdbTable enhances JTable, its corresponding Swing component, by adding the ability to easily display and edit data from a DataExpress DataSet. DataSets are row-oriented: you are always positioned at one row, you can only edit that row, and your edits must pass validation checks before you can move to a new row. JdbTable is optimized to handle database data, and this specialization brings with it a number of changes from JTable: All of this assumes that the JdbTable's dataSet property is set or its model is connected to a DataSet. It is possible to use a JdbTable without using a DataSet, populating it as you would a JTable and getting some extra behavior that JTable does not provide. However, it is much more common to populate a JdbTable from a DataSet.

Like other scrollable Swing and dbSwing components, JdbTable will not be scrollable unless it is placed in the viewport area of a TableScrollPane or JScrollPane. Also, it won't have row and column headers because the headers are actually added to the header area of the scroll pane. dbSwing's TableScrollPane, an extension of JScrollPane, includes options that speed up scrolling, especially in large tables.

Selection, field validation, and row posting

Each time you end edit mode in a field in a DataSet, JBuilder checks that the new value can be parsed to the expected data type and that it satisfies any validation checks (minimum value, for example) defined for its Column. If the value passes these tests, it can be "put." If it fails, an error message is displayed and the field remains in edit mode.

JdbTable supports the DataSet's focus on validating one field value at a time by restricting editing to a single cell and highlighting that cell. When you're done editing a field value, use Enter or Tab to invoke end-edit processing.

JBuilder also performs row-level validation, checking, for example, that all required columns have non-blank values and that columns for which the DataSet has unique indexes do not contain values that duplicate existing rows. Again, an error message is displayed if these checks fail.

If the checks pass, all new and modified field values are saved to the DataSet; the row is "posted." JdbTable supports the DataSet's row-level validation by refusing to navigate to a new row if changes to the current row can't be posted.

To select an entire row in a JdbTable, set its rowSelectionAllowed property to true and its cellSelectionEnabled property to false. If you find that the visual indication that a cell has focus is too subtle, you can use the editableFocusedCellForeground and editableFocusedCellBackground properties to distinguish it.

The following list summarizes JdbTable's navigation and editing keystrokes:

Row operations

To sort a JdbTable by the values in a column, click that column's header. To toggle between ascending and descending order, click the header again. You can also right-click anywhere in the data of a JdbTable to open a popup menu of row operations. In addition to selecting a column to sort by, you can return to the DataSet's original, unsorted order.

JBuilder, like most database servers, appends newly inserted rows at the end of a DataSet. In "<unsorted>" order, a new row will "fly away" to the end of the DataSet when you navigate off it or post it.

To insert a new row into a JdbTable, use Ctrl+Ins. Columns that have default values defined will contain those values and all other columns will be empty. If you navigate off a row that has only blank or default values, it will be discarded. To delete a row, use Ctrl+Del. You can also use the popup menu to insert and delete rows. Insert and delete operations may be disallowed by the DataSet.

JdbNavToolBar is very often used with JdbTable. JdbNavToolBar automatically detects and binds to the active component's DataSet. It can be used to navigate, insert and delete rows, and save DataSet changes back to a server, and also provides visual indications of editing status and row position.

Customizing a table's appearance

The default appearance and behavior of a JdbTable is only a starting point. JTable has many properties that customize how it looks and works, and JdbTable adds others. Here are some appearance changes that are easy to make:

Column headers: By default, a JdbTable has a column header with black text on a gray background. Each column's default text is the caption property of the corresponding DataSet Column. To change the text, set the caption property. To display several lines of text in a column header, separate them with newline characters, '\n', in the Column's caption. To hide column headers, set the columnHeaderVisible property to false.

You can also change the color or font of the column header or disallow rearrangement of columns at runtime with code like this:

myJdbTable.getTableHeader().setBackground(Color.cyan);
myJdbTable.getTableHeader().setReorderingAllowed(false);

Row headers: By default, the leftmost column of a JdbTable displays row numbers. You can suppress it by setting the rowHeaderVisible property to false.

Grid properties: By default, table cells are separated horizontally and vertically by thin gray lines. To change their color, set the gridColor property. To hide grid lines, set the showHorizontalLines property and/or the showVerticalLines property to false. To alter the margin between cell values and the grid, set the intercellSpacing property. This property requires two integers, the horizontal and vertical margins in pixels.

Table cell properties: To customize cells in the table, you can set the font, foreground, background, selectionForeground, selectionBackground, editableFocusedCellForeground and editableFocusedCellBackground properties, among others.

Hiding columns in a JdbTable

If you don't want to display all of a DataSet's Columns, use JdbTable's hiddenColumns property. This property can't be set in JBuilder's UI designer because it takes an array, but the code is easy, for example:

myJdbTable.setHiddenColumns(new int[] { 5, 6, 8 } );
where 5, 6, and 8 are the ordinals (counting from 0) of the data set columns that should not be displayed. Put this code in jbInit(). To reset, pass null instead of an array of ints.

Customizing columns in a JdbTable

JdbTable's customColumns property associates TableColumn objects with columns of a JdbTable. The TableColumns may be customized, or they may be used only to control the order of columns in the JdbTable.

In order to describe customized columns, first note the three types of columns:

As part of the call to setCustomColumns, you include an array of numbers that specify the column of the table in which to display each TableColumn. To reorder columns in a JdbTable, you define a TableColumn for each column you want to move and set its value in this array appropriately. To accept a TableColumn's default position, use -1. Instead of reordering columns, or in addition, you can modify a JdbTable by setting properties on your TableColumns.

Properties include:

The customColumns property does not require a DataExpress DataSet. You can fill a JdbTable with data from another source by setting its model property to any TableModel, then take advantage of customColumns and other JdbTable features that enhance display and runtime manipulation of data.

The customColumns property cannot be set through JBuilder's UI designer but some preparation can be done in the designer. Use the BeanChooser to select a javax.swing.table.TableColumn object, drop it into a design, and set its modelIndex property. If this TableColumn is being used only to set the position of a column in a JdbTable, no other properties need be set. Otherwise, the TableColumn may be customized by setting other properties. You must code the actual call to setCustomColumns() because it takes a CustomColumnsDescriptor, which can't be manipulated in the designer. See the online Help or source code for JdbTable's setCustomColumns() method for an example.

TableColumn properties and hiding and reordering JdbTable columns will not be shown in the UI designer.

Cell renderers and editors

Swing uses renderers to display data and editors to edit data. Different components use different renderers and editors. JTable defines simple default renderers of type DefaultTableCellRenderer for numeric, boolean, image, icon, and object columns. JdbTable usually replaces JTable's defaults with renderers and editors from the dbSwing package that perform better and support display and edit masks. However, if you explicitly set a column's renderer or editor, JdbTable will not replace it.

The default cell editor for a column with a picklist is a combo box cell editor. The column is displayed as usual. When edited, a cell in the column looks and works very much like a JdbComboBox; a drop-down list of values to choose from is displayed and the value selected from the list becomes the new field value. To get this behavior, set the picklist property of a Column in a DataSet just as you would when using a JdbComboBox and display the DataSet in a JdbTable.

When a column whose data type is Variant.INPUTSTREAM is displayed in a JdbTable, its default cell editor is a TableImageEditor. As much of the image as will fit is displayed in the cell. If you double-click the cell, a dialog opens that displays the full image, with scrollbars if necessary, and allows you to choose a new image file. TableImageEditor can display GIFs, JPGs, and any BMP file that you can view in Windows Paint. If you display an INPUTSTREAM column that does not contain images in a JdbTable, you should provide a custom cell renderer and editor for it.

dbSwing also provides a read-only editor, TableImageReadOnlyEditor, that also displays images in a dialog but does not provide a file chooser and therefore does not allow the field value to be edited. TableImageReadOnlyEditor is never installed as the default cell editor for a column, but can be used instead of TableImageEditor if desired.

To replace the default cell renderer or editor in a column of a JdbTable, set the corresponding Column's itemPainter or itemEditor property. For example, to display a column of images but prevent changes to the data, set the Column's itemEditor property to an instance of TableImageReadOnlyEditor. If you're working in the UI designer, you can use the BeanChooser to select TableImageReadOnlyEditor from the com.borland.dbswing package, drop an instance into the component tree, and set the Column's itemEditor property to it.

Before you write a custom cell renderer, consider using a ColumnPaintListener instead. It passes you almost the same parameters as a cell renderer, so you can do almost anything with a ColumnPaintListener that you would do in a cell renderer. A ColumnPaintListener differs from a cell renderer in a few ways:

If you decide to write a custom cell renderer for JdbTable, you will probably extend DBCellRenderer. It's a public inner class of JdbTable, so the syntax is unusual. Notice the extends clause and the call to super() in the constructor of this example. This custom cell renderer displays negative numbers in red:
import java.awt.*;
import javax.swing.*;
import com.borland.dbswing.*;

public class NegativeNumberRenderer extends JdbTable.DBCellRenderer {

   public NegativeNumberRenderer(JdbTable jdbTable) {
     jdbTable.super();
   }
   public Component getTableCellRendererComponent(JTable table, Object value,
       boolean isSelected, boolean hasFocus, int row, int column) {
     super.getTableCellRendererComponent(table,value, isSelected, hasFocus, row, column);
     if (value != null) {
       try {
        // Compare numeric value of string to zero. This assumes that a negative
        // value has a leading minus sign, so only handles simple numeric formats
        if (Double.parseDouble((String) value) < 0.0d)
          super.setForeground(Color.red);
       }
       // Use the default foreground if we can't get a number from the string
       catch (NumberFormatException nfe) {
	   }
     }
     return this;
   }
}

TableColumns

When you set a JdbTable's dataSet property, each visible column in the DataSet is displayed in a column in the JdbTable. More specifically, each com.borland.dx.dataset.Column object is associated with a javax.swing.table.TableColumn object. Often you can give a JdbTable the desired appearance and behavior by setting Column properties. For example, JdbTable inherits font, color, alignment, and width settings from the Columns in its DataSet. This is the easy way to customize a JdbTable.

Sometimes, you have to create TableColumns yourself so you can set their properties. For example, you have to set TableColumn properties to control runtime resizing of an individual column in a JdbTable. More often, you have a choice: instead of instantiating a TableColumn and setting a property on it, you can get the same result or a very similar result another way.

Unless there's a compelling reason to use a TableColumn, we recommend the alternative approach in these cases:

See also: Deprecated and moved functionality in dbswing


JdbTable variables

Variables implemented in java.awt.Component

Variables implemented in javax.swing.JComponent

Variables implemented in javax.swing.JTable

JdbTable constructors

JdbTable properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.awt.Component

Properties implemented in java.awt.Container

Properties implemented in java.lang.Object

Properties implemented in javax.swing.JComponent

Properties implemented in javax.swing.JTable

JdbTable methods

Methods implemented in this class

Methods implemented in java.awt.Component

Methods implemented in java.awt.Container

Methods implemented in java.lang.Object

Methods implemented in javax.swing.JComponent

Methods implemented in javax.swing.JTable

JdbTable event listeners


JdbTable constructors

JdbTable()

  public JdbTable()
Constructs a JdbTable component by calling the null constructor of its superclass.

JdbTable(int, int)

  public JdbTable(int numColumns, int numRows)
Constructs a JdbTable component by calling the constructor of its superclass that takes integer values for the number of columns and rows in the table.

Parameters:

numColumns
The number of columns in the table. The columns have names of the form "A", "B", "C", and so on.
numRows
The number of rows in the table.

JdbTable(java.lang.Object[][], java.lang.Object[])

  public JdbTable(Object[][] data, Object[] columnNames)
Constructs a JdbTable component by calling the constructor of its superclass that takes a two-dimensional array of Objects for the table's data and an array of Objects for the table's column names.

Parameters:

data
The data for the new table.
columnNames
The names of the column of the table.

JdbTable(java.util.Vector, java.util.Vector)

  public JdbTable(Vector data, Vector columnNames)
Constructs a JdbTable component by calling the constructor of its superclass that takes Vectors for the table's data and its column names.

Parameters:

data
The data for the new table.
columnNames
The names of the column of the table.

JdbTable(javax.swing.table.TableModel)

  public JdbTable(TableModel dm)
Constructs a JdbTable component by calling the constructor of its superclass and passing to it a TableModel as the source of the table's data. It uses a default column model and a default selection model.

Parameters:

dm
The data model for the new table.

JdbTable(javax.swing.table.TableModel, javax.swing.table.TableColumnModel)

  public JdbTable(TableModel dm, TableColumnModel cm)
Constructs a JdbTable component by calling the constructor of its superclass and passing to it a TableModel and TableColumnModel as the source of the table's data. It uses a default selection model.

Parameters:

dm
The data model for the new table.
cm
The column model for the table.

JdbTable(javax.swing.table.TableModel, javax.swing.table.TableColumnModel, javax.swing.ListSelectionModel)

  public JdbTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Constructs a JdbTable component by calling the constructor of its superclass and passing to it a TableModel, TableColumnModel, and ListSelectionModel. If any of these parameters are null, the constructor initializes the table with a default model.

Parameters:

dm
The table model for the table.
cm
The column model for the table.
sm
The row selection model for the table.

JdbTable properties

autoSelection

 public boolean isAutoSelection()
 public void setAutoSelection(boolean autoSelection)
Returns and sets whether JdbTable automatically updates the selection model whenever the data model changes. Setting this property to false, for example, prevents JdbTable from setting the selection when it is first displayed. The default property value is true.

columnHeaderVisible

 public boolean isColumnHeaderVisible()
 public void setColumnHeaderVisible(boolean columnHeaderVisible)
Determines whether the column header displaying the column names is visible. If columnHeaderVisible is true, the column header is visible; if it is false, the column header is not visible.

columnSortEnabled

 public boolean isColumnSortEnabled()
 public void setColumnSortEnabled(boolean enableSort)
Returns and sets whether clicking in a column of the table header sorts rows by that column. The default value is true.

customColumns

 public CustomColumnsDescriptor getCustomColumns()
 public void setCustomColumns(CustomColumnsDescriptor customColumnDescriptor)
When used as a getter, customColumns returns the CustomColumnsDescriptor defining the customized TableColumn properties of this table.

When used as a setter, customColumns sets custom properties for a subset of this table's TableColumns.

Parameters:

customColumnDescriptor
The container class containing the customized column properties for the JdbTable.

Hidden columns take precedence over customized columns, so customized properties on hidden columns are ignored.

If the model used by the JdbTable undergoes a structural change (i.e., columns are added or removed) then customColumns will likely need to be set again with model indices applicable to the new model. Setting a null CustomColumnsDescriptor removes all customized column properties, and should be done before the model (DataSet) changes to avoid setting customized properties on columns which no longer exist in the new model.

Example:

// This code fragment assumes that elsewhere in the program 
// you have already instantiated a JdbTable called jdbTable1, 
// which has a default model.  

// This example code shows how to instantiate a non-default 
// model, define custom columns, then assign the non-default 
// model to the JdbTable and set the table's CustomColumnsDescriptor 
// to use the newly defined custom columns.

TableModel tableModel = new AbstractTableModel() {
  
  // This instantiates the model, and at the same time implements
  // the following methods of TableModel, which is an interface. 

  public int getColumnCount() {
    return 4;
  }
  public int getRowCount() {
    return 1;
  }
  public Object getValueAt(int row, int col) {
    return "";
  }
  public boolean isCellEditable(int row, int col) {
    return true;
  }
  public String getColumnName(int index) {
    if (index == 0) {
      return "Name";
    }
	else if (index == 1) {
	  return "Address";
	}
	else if (index == 2) {
	  return "Phone";
	}
	else if (index == 3) {
	  return "email";
	}
	return null;
  }
};
	TableColumn addressColumn = new TableColumn(1);
	// sets preferred width of Address column in the table model
	addressColumn.setPreferredWidth(225);

	TableColumn phoneColumn = new TableColumn(2);
	// sets multi-line header on Phone column in the table model
	phoneColumn.setHeaderValue(new String [] { "Phone", "Number"});

	TableColumn emailColumn = new TableColumn(3);
	// sets custom cell renderer on email column in the table model
	emailColumn.setCellEditor(new DefaultCellEditor(new JComboBox(new String[] {"me@mycompany.com", "you@yourcompany.com"} )));

	// Set a null CustomColumnsDescriptor before assigning
	// the new model to the JdbTable to avoid setting
	// customized properties on columns which no longer exist
	// in the new model.
	jdbTable1.setCustomColumns(null);
 	
	// set table's new non-default table model
	jdbTable1.setModel(tableModel);

	// Set a new CustomColumnsDescriptor which makes the
	// email column appear as the third column in table, the
	// address column appear in its 'natural' position, and
	// the phoneColumn appear as the first column in the table.
	jdbTable1.setCustomColumns(new CustomColumnsDescriptor(new int [] { 2, -1, 0}, new TableColumn [] { emailColumn, addressColumn, phoneColumn}));
   
   

Note: The TableColumn's identifier property is used internally by JdbTable. When using a DataSet, you should not set this property. Setting this property (whether or not using a DataSet) will prevent JdbTable from properly merging new hidden or custom columns with an existing TableColumnModel.

dataSet

 public DataSet getDataSet()
 public void setDataSet(DataSet dataSet)
Returns and sets the DataSet used to build the TableModel that contains the data for the table. setDataSet() creates an instance of DBTableModel with the given DataSet, then sets it as the table's model by calling setModel(). If the DataSet is null, the DBTableModel creates an empty table model.

editable

 public boolean isEditable()
 public void setEditable(boolean editable)
Returns and sets whether entries of the table are editable or not:

editableFocusedCellBackground

 public Color getEditableFocusedCellBackground()
 public void setEditableFocusedCellBackground(Color focusedCellBackground)
Returns and sets the background color of the currently focused, editable cell.

editableFocusedCellForeground

 public Color getEditableFocusedCellForeground()
 public void setEditableFocusedCellForeground(Color focusedCellForeground)
Returns and sets the foreground color of the currently focused, editable cell.

hiddenColumns

 public int[] getHiddenColumns()
 public void setHiddenColumns(int[] hiddenColumns)
Returns and sets the table model columns that are hidden from the table's display.

Invoking setHiddenColumns() always causes the table's column model to be rebuilt regardless of the value of autoCreateDefaultColumnsFromModel(). Each element of the array is the index of the column in the table model you want to be a hidden column.

Hidden columns take precedence over customized columns.

The order of the elements in the array is not significant. Invalid model indexes are ignored.

If the model used by this table undergoes a structural change (i.e., columns are added or removed) then this property will likely need to be set again with model indices applicable to the new model. Specifying a null value resets (removes) all existing hidden columns, and should be done before the model (DataSet) changes to avoid hiding columns which no longer exist in the new model, or accidentally hiding columns in the new model which shouldn't be hidden.

The hiddenColumns array is not cloned. If you make changes to the array after this property has been set, unexpected side effects can occur.

popupMenuEnabled

 public boolean isPopupMenuEnabled()
 public void setPopupMenuEnabled(boolean popupEnabled)
Returns and sets whether right-clicking in the table displays a pop-up menu. The default value is true.

See also: createPopupMenu

rowHeader

 public TableRowHeader getRowHeader()
 public void setRowHeader(TableRowHeader rowHeader)

A JdbTable has a TableRowHeader by default, which is customizable through its properties. To add behavior not already provided by TableRowHeader, create a new class extending it, and set it as the new row header.

Setting a null row header has the side effect of hiding the row header. Setting a non-null row header has the side effect of displaying the row header if it was not already visible.

rowHeaderVisible

 public boolean isRowHeaderVisible()
 public void setRowHeaderVisible(boolean rowHeaderVisible)
Determines whether a row header is visible. If rowHeaderVisible is true, the row header is visible; if it is false, the row header is not visible. The default is true.

Using setRowHeader() to set a new non-null row header has the side effect of setting rowHeaderVisible to true.

smartColumnWidths

 public boolean isSmartColumnWidths()
 public void setSmartColumnWidths(boolean smartColumnWidths)
Determines if the default initial column widths are calculated by the model column's data type. If they are, smartColumnWidths is true. The default is true.

When using a DataSet as the table's model, set this property value to true to have default column widths determined by analysis of the corresponding DataSet Column.

A customized column's preferredSize property takes precedence over this property. Therefore, to override the smart default column width, define a custom column and set its width. Or you can override the getDefaultTableColumnWidth() method that contains the algorithm for determining the default width of a column.

Note: The value of this property is ignored if a DataSet was not used to build this table's model because data type information is not available.

See also: customColumns

tableHeader

 public void setTableHeader(JTableHeader tableHeader)
Sets the header for the table with the JTableHeader specified as the value of tableHeader.

visible

 public void setVisible(boolean visible)
Sets whether the table is visible. If the visible parameter is true, the table is visible; if it is false, the table is not visible. The default is true.

JdbTable methods

addNotify()

  public void addNotify()
Calls addNotify() of the superclass and opens the DataSet.

Overrides: javax.swing.JTable.addNotify()

configureEnclosingScrollPane()

  protected void configureEnclosingScrollPane()
Adds the table's column header to the enclosing ScrollPane's ColumnHeaderView. The configureEnclosingScrollPane() method is normally invoked only once, when addNotify() is called.

Overrides: javax.swing.JTable.configureEnclosingScrollPane()

createDefaultColumnsFromModel()

  public void createDefaultColumnsFromModel()
Rebuilds the TableColumnModel from the TableModel and overrides JTable's method of the same name.

createDefaultColumnsFromModel() is called by JTable whenever the table model changes and AutoCreateColumnsFromModel is true. It is also called by setHiddenColumns() and setCustomizedColumns() regardless of the state of AutoCreateColumnsFromModel.

createDefaultColumnsFromModel adds uncustomized columns to the table column model in the same order as they are returned by the model. createDefaultColumnsFromModel normally isn't called until a table has been realized. This improves performance at load time, since the column model only needs to be built once - after multiple properties have been set - rather than every time a property changes.

Overrides: javax.swing.JTable.createDefaultColumnsFromModel()

createDefaultDataModel()

  protected TableModel createDefaultDataModel()
Creates the default data model at JdbTable instantiation time and overrides JTable's implementation to create a DBTableModel instead of a DefaultTableModel.

Overrides: javax.swing.JTable.createDefaultDataModel()

createDefaultTableHeader()

  protected JTableHeader createDefaultTableHeader()
Returns a JTableHeader. Note that the instance of JTableHeader which is returned by this method can't accept keyboard focus. This is true because when createDefaultTableHeader() instantiates the JTableHeader, it overrides the methods isFocusTraversable() and isRequestFocusEnabled() to prevent the JTableHeader from accepting keyboard focus.

Overrides: javax.swing.JTable.createDefaultTableHeader()

createPopupMenu()

  protected JPopupMenu createPopupMenu()
Creates JdbTable's default right-click popup menu.

ensureRowIsVisible(int)

  public void ensureRowIsVisible(int row)
Makes the specified row visible and throws an IllegalArgumentException if the row is not in the valid range.

Parameters:

row
The row whose visibility is in question.

getDefaultCellEditor(com.borland.dx.dataset.Column)

  protected TableCellEditor getDefaultCellEditor(Column dataSetColumn)
Returns the default editor to use for the specified Column.

getDefaultCellRenderer(com.borland.dx.dataset.Column)

  protected TableCellRenderer getDefaultCellRenderer(Column dataSetColumn)
Returns the default renderer to use for the specified Column.

getDefaultTableColumnWidth(com.borland.dx.dataset.Column)

  protected int getDefaultTableColumnWidth(Column dataSetColumn)
Returns a default pixel width for a TableColumn based on a DataSet Column's type. This method is called by createDefaultColumnsFromModel() as it attempts to inherit TableColumn properties from DataSet Column properties.

getMaxCaptionWidth(java.lang.Object, java.awt.Font)

  protected int getMaxCaptionWidth(Object columnHeaderValue, Font font)
Returns the maximum caption width based on the font and the column header value. This method is called by createDefaultColumnsFromModel() if the table model is null and smartColumnWidths is true.

getStringWidth(java.lang.String, java.awt.Font)

  protected int getStringWidth(String string, Font font)
Returns the width of the string size based on the font.

initializeLocalVars()

  protected void initializeLocalVars()
Initializes table properties to their default values.

Overrides: javax.swing.JTable.initializeLocalVars()

isCellEditable(int, int)

  public boolean isCellEditable(int row, int column)
Overrides the JTable's default implementation to account for the value of the editable property.

Overrides: javax.swing.JTable.isCellEditable(int, int)

isCellSelected(int, int)

  public boolean isCellSelected(int row, int column)

Overrides: javax.swing.JTable.isCellSelected(int, int)

isCellValid(javax.swing.table.TableCellEditor)

  protected boolean isCellValid(TableCellEditor cellEditor)
When a user tries to save a table cell value, the table asks whether to stop editing the cell. At that point, JdbTable checks to see if the cell editor value is valid. If not, it throws an exception to display to the user. The reason the cell editor is passed as an argument is because it knows the currently edited value, which may still be incomplete.

prepareEditor(javax.swing.table.TableCellEditor, int, int)

  public Component prepareEditor(TableCellEditor editor, int row, int column)
Overrides the JTable's default implementation to provide support to JdbTable's custom cell editors.

Overrides: javax.swing.JTable.prepareEditor(javax.swing.table.TableCellEditor, int, int)

prepareRenderer(javax.swing.table.TableCellRenderer, int, int)

  public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
Overrides the JTable's default implementation to provide support to JdbTable's custom cell renderers.

Overrides: javax.swing.JTable.prepareRenderer(javax.swing.table.TableCellRenderer, int, int)

removeNotify()

  public void removeNotify()
Calls the removeNotify() method of the superclass, sets the rowHeaderVisible and columnHeaderVisible properties to false, and sets addNotifyCalled to false.

Overrides: javax.swing.JComponent.removeNotify()

updateUI()

  public void updateUI()
Overrides JTable's updateUI() method to make a few platform-independent UI changes. First, the default actions for Enter and Shift+Enter are changed to behave like Tab and Shift+Tab, respectively. Then, Ctrl+Ins and Ctrl+Del are bound to the insert and delete row actions.

Overrides: javax.swing.JTable.updateUI()


JdbTable event listeners

This component is a source for the following event sets.

ancestor

 public void addAncestorListener(javax.swing.event.AncestorListener )
 public void removeAncestorListener(javax.swing.event.AncestorListener )

component

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

container

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

focus

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

inputMethod

 public synchronized void addInputMethodListener(java.awt.event.InputMethodListener )
 public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )

key

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

mouse

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

mouseMotion

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

propertyChange

 public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener )
 public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )

vetoableChange

 public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener )
 public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )