Class Com - Sun.java - Swing.jtable
Class Com - Sun.java - Swing.jtable
Class com.sun.java.swing.JTable
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--com.sun.java.swing.JComponent
|
+--com.sun.java.swing.JTable
Because the JTable is now much easier to set up with custom models the DefaultTableModel
is less useful than it was in previous releases. Instead of copying the data in an application
into the DefaultTableModel, we recommend wrapping it in the methods of the TableModel
interface and passing the real data to the JTable as above. This technique is nearly as
concise as using a DefaultTableModel and starting this way has a number of advantages
over the longer term. In particular: it is a scalable technique, is easier to handle dynamic or
editable tables and often results in much more efficient applications because the model is
free to choose the internal representation that best suits the data.
The "Table" directory in the examples/demo area gives a number of complete examples of
JTable usage, covering how the JTable can be used to provide an editable view of data taken
from a database and how to modify the columns in the display to use specialized renderers
and editors. For example, overriding AbstractTableModel's getColumnClass() method to
return a value of ImageIcon.class for a given column allows icons to be displayed, while
returning a value of Number.class allows digits to be right-justified in the column.
The JTable uses integers exclusively to refer to both the rows and the columns of the model
that it displays. The JTable simply takes a tabular range of cells and uses getValueAt(int,
int) to retrieve and display the appropriate values from the model.
If getTableHeader().setReorderingAllowed(boolean) is used to enable column reordering
columns may be rearranged in the JTable so that the view's columns appear in a different
order to the columns in the model. This does not affect the implementation of the model at
all: when the columns are reordered, the JTable maintains the new order of the columns
internally and converts its column indices before querying the model.
So, when writing a TableModel, it is not necessary to listen for column reordering events as
the the model will be queried in its own co-ordinate system regardless of what is happening
in the view. In the examples area there is a demonstration of a sorting algorithm making
use of exactly this technique to interpose yet another co-ordinate system where the order of
the rows is changed, rather than the order of the columns.
A regra geral para a API JTable e as APIs de todas as suas classes associadas, incluindo o
modelo de coluna e os modelos de seleção de linha e coluna, é: métodos que usam índices
inteiros para linhas e colunas sempre usam o sistema de coordenadas da exibição . Existem
três exceções a esta regra:
O TableColumn fornece um slot para manter um identificador ou "tag" para cada coluna e o
JTable e o TableColumModel suportam as conveniências getColumn (ID do objeto) para
localizar colunas por seu identificador. Se nenhum identificador for definido
explicitamente, TableColumn retornará seu valor de cabeçalho (o nome da coluna) como
padrão. Um identificador diferente, que pode ser de qualquer tipo, pode ser definido
usando o método setIdentifier() da TableColumn . Todas as funções da JTable operam
corretamente independentemente do tipo e exclusividade desses identificadores.
Consulte Como usar tabelas no Tutorial Java para obter mais documentação.
Para obter as teclas do teclado usadas por este componente nas execuções padrão de
aparência e comportamento (L&F), consulte as atribuições de teclas JTable .
Aviso: os objetos serializados desta classe não serão compatíveis com versões futuras do
swing. O suporte de serialização atual é apropriado para armazenamento de curto prazo ou
RMI entre aplicativos Swing1.0. Não será possível carregar objetos Swing1.0 serializados
com versões futuras do Swing. A versão JDK1.2 do Swing será a linha de base de
compatibilidade para a forma serializada dos objetos Swing.
Veja também:
Formulário serializado
Resumo da classe interna
protegido JTable.AccessibleJTable
A classe usada para obter a função acessível para este objeto.
Classes internas herdadas da classe com.sun.java.swing. JComponent
JComponent.AccessibleJComponent
Resumo do campo
int estático AUTO_RESIZE_ALL_COLUMNS
Durante todas as operações de redimensionamento, redimensionar
proporcionalmente todas as colunas
int estático AUTO_RESIZE_LAST_COLUMN
Durante todas as operações de redimensionamento, aplique ajustes
apenas na última coluna
int estático AUTO_RESIZE_NEXT_COLUMN
Quando uma coluna é ajustada na interface do usuário, ajuste a
próxima coluna da maneira oposta
int estático AUTO_RESIZE_OFF
Não ajusta as larguras das colunas automaticamente, use uma barra
de rolagem
int estático AUTO_RESIZE_SUBSEQUENT_COLUMNS
Durante o ajuste da interface do usuário, altere as colunas
subsequentes para preservar a largura total
booleano protegido autoCreateColumnsFromModel
A tabela consultará o TableModel para criar o conjunto padrão de
colunas se isso for verdadeiro.
int protegido autoResizeMode
Este valor de modo determina se a tabela redimensiona
automaticamente a largura das colunas da tabela para ocupar toda a
largura da tabela e como ela faz o redimensionamento.
Editor de TableCell cellEditor
protegido O objeto que sobrescreve o espaço da tela ocupado pela célula atual
e permite ao usuário alterar esse conteúdo.
booleano protegido cellSelectionEnabled
Se isso for verdade, uma seleção de linha e uma seleção de coluna
podem não estar vazias ao mesmo tempo, as células selecionadas são as
células cuja linha e coluna estão selecionadas.
TableColumnModel columnModel
protegido O TableColumnModel da tabela
TableModel dataModel
protegido O TableModel da tabela
Hashtable defaultEditorsByColumnClass
protegido Uma tabela de objetos que exibe e edita o conteúdo de uma célula,
indexada por classe.
Hashtable defaultRenderersByColumnClass
protegido Uma tabela de objetos que exibe o conteúdo de uma célula,
indexada por classe.
int protegido editingColumn
Identifica a coluna da célula que está sendo editada.
int protegido editingRow
Identifica a linha da célula que está sendo editada.
componente editorComp
protegido Se estiver editando, Componente que está manipulando a edição.
cor protegida gridColor
A cor da grade
Dimensão preferidoViewportSize
protegida Usado pela interface Scrollable para determinar a área visível
inicial
int protegido rowHeight
A altura de todas as linhas na tabela
int protegido rowMargin
A margem de altura entre as linhas
booleano protegido rowSelectionAllowed
Seleção de linha permitida nesta tabela
cor protegida selectionBackground
A cor de fundo das células selecionadas
cor protegida selectionForeground
A cor de primeiro plano das células selecionadas
ListSelectionModel selectionModel
protegido O ListSelectionModel da tabela, usado para acompanhar as seleções
de linha
booleano protegido showHorizontalLines
A tabela desenha linhas horizontais entre as células se
showHorizontalLines for true
booleano protegido showVerticalLines
A tabela desenha linhas verticais entre as células se
showVerticalLines for true
JTableHeader tableHeader
protegido O TableHeader trabalhando com a tabela
Campos herdados da classe com.sun.java.swing. JComponent
accessContext , listenerList , TOOL_TIP_TEXT_KEY , ui , UNDEFINED_CONDITION ,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED ,
WHEN_IN_FOCUSED_WINDOW
Campos herdados da classe java.awt. Componente
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT ,
TOP_ALIGNMENT
Resumo do Construtor
JTable ()
Constrói uma JTable padrão que é inicializada com um modelo de dados padrão, um
modelo de coluna padrão e um modelo de seleção padrão.
JTable (int numRows, int numColumns)
Constrói uma JTable com numRows e numColumns de células vazias usando o
DefaultTableModel.
JTable ( Object [][] rowData, Object [] columnNames)
Constrói uma JTable para exibir os valores no array bidimensional, rowData , com
nomes de colunas, columnNames .
JTable ( TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Constrói uma JTable que é inicializada com dm como modelo de dados, cm como
modelo de coluna e sm como modelo de seleção.
JTable ( TableModel dm, TableColumnModel cm)
Constrói uma JTable que é inicializada com dm como modelo de dados, cm como
modelo de coluna e um modelo de seleção padrão.
JTable ( TableModel dm)
Constrói uma JTable que é inicializada com dm como modelo de dados, um modelo
de coluna padrão e um modelo de seleção padrão.
JTable ( Vector rowData, Vector columnNames)
Constrói uma JTable para exibir os valores no Vetor de Vetores, rowData , com nomes
de colunas, columnNames .
Resumo do método
vazio addColumn ( TableColumn aColumn)
Anexa aColumn ao final da matriz de colunas mantidas pelo
modelo de coluna da JTable.
vazio addColumnSelectionInterval (int index0, int index1)
Adiciona as colunas de index0 a index0 inclusive à seleção atual.
vazio addNotify ()
ChamadasconfigureEnclosingScrollPane.
vazio addRowSelectionInterval (int index0, int index1)
Adiciona as linhas de index0 a index0 inclusive à seleção atual.
vazio clearSelection ()
Desmarca todas as colunas e linhas selecionadas.
vazio columnAdded ( TableColumnModelEvent e)
Informa aos ouvintes que uma coluna foi adicionada ao modelo.
int columnAtPoint ( Point point)
Retorna o índice da coluna em que o ponto está, ou -1 se estiver
fora dos limites do receptor.
vazio columnMarginChanged ( ChangeEvent e)
Informa aos ouvintes que uma coluna foi movida devido a uma
alteração de margem.
vazio columnMoved ( TableColumnModelEvent e)
Informa aos ouvintes que uma coluna foi reposicionada.
vazio columnRemoved ( TableColumnModelEvent e)
Informa aos ouvintes que uma coluna foi removida do modelo.
vazio columnSelectionChanged ( ListSelectionEvent e)
Informa aos ouvintes que o modelo de seleção do
TableColumnModel foi alterado.
vazio protegido configureEnclosingScrollPane ()
Se o JTable for o viewportView de um JScrollPane envolvente (a
situação usual), configure este ScrollPane, entre outras coisas, instalando
o tableHeader da tabela como o columnHeaderView do scrollpane.
int convertColumnIndexToModel (int viewColumnIndex)
Retorna o índice da coluna no modelo cujos dados estão sendo
exibidos na coluna viewColumnIndex no display.
int convertColumnIndexToView (int modelColumnIndex)
Retorna o índice da coluna na exibição que está exibindo os dados
da coluna modelColumnIndex no modelo.
TableColumnModel createDefaultColumnModel ()
protegido Retorna o objeto de modelo de coluna padrão que é um
DefaultTableColumnModel.
vazio createDefaultColumnsFromModel ()
Este método criará colunas padrão para a tabela a partir do modelo
de dados usando os métodos getColumnCount() e getColumnClass()
definidos na interface TableModel.
TableModel createDefaultDataModel ()
protegido Retorna o objeto de modelo de tabela padrão que é um
DefaultTableModel.
vazio protegido createDefaultEditors ()
Cria editores de célula padrão para objetos, números e valores
booleanos.
vazio protegido createDefaultRenderers ()
ListSelectionModel createDefaultSelectionModel ()
protegido Retorna o objeto modelo de seleção padrão que é um
DefaultListSelectionModel.
JTableHeader createDefaultTableHeader ()
protegido Retorna o objeto de cabeçalho da tabela padrão que é um
JTableHeader.
JScrollPane estático createScrollPaneForTable ( JTable aTable) Obsoleto
. A partir da versão 1.0.2 do Swing, substituído por new
JScrollPane(aTable).
void sizeColumnsToFit(int resizingColumn)
This method will resize one or more ot the columns in the table so
that the total width of all of the JTable's columns will be equal to the
width of the table.
void tableChanged(TableModelEvent e)
The TableModelEvent should be constructed in the co-ordinate
system of the model, the appropriate mapping to the view co-ordinate
system is performed by the JTable when it recieves the event.
void updateUI()
Notification from the UIManager that the L&F has changed.
void valueChanged(ListSelectionEvent e)
Invoked when the selection changes -- repaints to show the new
selection.
Methods inherited from class com.sun.java.swing.JComponent
addAncestorListener , addPropertyChangeListener , addVetoableChangeListener ,
computeVisibleRect , contains , createToolTip , firePropertyChange , firePropertyChange ,
firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange ,
firePropertyChange , firePropertyChange , firePropertyChange , fireVetoableChange ,
getActionForKeyStroke , getAlignmentX , getAlignmentY , getAutoscrolls , getBorder ,
getBounds , getClientProperty , getComponentGraphics , getConditionForKeyStroke ,
getDebugGraphicsOptions , getGraphics , getHeight , getInsets , getInsets , getLocation ,
getMaximumSize , getMinimumSize , getNextFocusableComponent , getPreferredSize ,
getRegisteredKeyStrokes , getRootPane , getSize , getToolTipLocation , getToolTipText ,
getTopLevelAncestor , getVisibleRect , getWidth , getX , getY , grabFocus , hasFocus ,
isDoubleBuffered , isFocusCycleRoot , isFocusTraversable , isLightweightComponent ,
isManagingFocus , isOpaque , isOptimizedDrawingEnabled , isPaintingTile ,
isRequestFocusEnabled , isValidateRoot , paint , paintBorder , paintChildren ,
paintComponent , paintImmediately , paintImmediately , processComponentKeyEvent ,
processFocusEvent , processKeyEvent , processMouseMotionEvent , putClientProperty ,
registerKeyboardAction , registerKeyboardAction , removeAncestorListener ,
removeNotify , removePropertyChangeListener , removeVetoableChangeListener , repaint
, repaint , requestDefaultFocus , requestFocus , resetKeyboardActions , reshape , revalidate
, scrollRectToVisible , setAlignmentX , setAlignmentY , setAutoscrolls , setBorder ,
setDebugGraphicsOptions , setDoubleBuffered , setEnabled , setMaximumSize ,
setMinimumSize , setNextFocusableComponent , setOpaque , setPreferredSize ,
setRequestFocusEnabled , setToolTipText , setUI , setVisible , unregisterKeyboardAction ,
update
Methods inherited from class java.awt.Container
add , add , add , add , add , addContainerListener , addImpl , countComponents ,
deliverEvent , doLayout , findComponentAt , findComponentAt , getComponent ,
getComponentAt , getComponentAt , getComponentCount , getComponents , getLayout ,
insets , invalidate , isAncestorOf , layout , list , list , locate , minimumSize ,
paintComponents , paramString , preferredSize , print , printComponents ,
processContainerEvent , processEvent , remove , remove , removeAll ,
removeContainerListener , setLayout , validate , validateTree
Methods inherited from class java.awt.Component
action , add , addComponentListener , addFocusListener , addInputMethodListener ,
addKeyListener , addMouseListener , addMouseMotionListener ,
addPropertyChangeListener , bounds , checkImage , checkImage , coalesceEvents ,
contains , createImage , createImage , disable , disableEvents , dispatchEvent , enable ,
enable , enableEvents , enableInputMethods , getBackground , getBounds , getColorModel ,
getComponentOrientation , getCursor , getDropTarget , getFont , getFontMetrics ,
getForeground , getInputContext , getInputMethodRequests , getLocale , getLocation ,
getLocationOnScreen , getName , getParent , getPeer , getSize , getToolkit , getTreeLock ,
gotFocus , handleEvent , hide , imageUpdate , inside , isDisplayable , isEnabled ,
isLightweight , isShowing , isValid , isVisible , keyDown , keyUp , list , list , list , location ,
lostFocus , mouseDown , mouseDrag , mouseEnter , mouseExit , mouseMove , mouseUp ,
move , nextFocus , paintAll , postEvent , prepareImage , prepareImage , printAll ,
processComponentEvent , processInputMethodEvent , processMouseEvent , remove ,
removeComponentListener , removeFocusListener , removeInputMethodListener ,
removeKeyListener , removeMouseListener , removeMouseMotionListener ,
removePropertyChangeListener , repaint , repaint , repaint , resize , resize , setBackground
, setBounds , setComponentOrientation , setCursor , setDropTarget , setFont ,
setForeground , setLocale , setLocation , setLocation , setName , setSize , setSize , show ,
show , size , toString , transferFocus
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait
Field Detail
AUTO_RESIZE_OFF
public static final int AUTO_RESIZE_OFF
AUTO_RESIZE_NEXT_COLUMN
public static final int AUTO_RESIZE_NEXT_COLUMN
When a column is adjusted in the UI, adjust the next column the opposite way
AUTO_RESIZE_SUBSEQUENT_COLUMNS
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS
AUTO_RESIZE_LAST_COLUMN
public static final int AUTO_RESIZE_LAST_COLUMN
During all resize operations, apply adjustments to the last column only
AUTO_RESIZE_ALL_COLUMNS
public static final int AUTO_RESIZE_ALL_COLUMNS
dataModel
protected TableModel dataModel
columnModel
protected TableColumnModel columnModel
selectionModel
protected ListSelectionModel selectionModel
tableHeader
protected JTableHeader tableHeader
rowHeight
protected int rowHeight
gridColor
protected Color gridColor
showHorizontalLines
protected boolean showHorizontalLines
showVerticalLines
protected boolean showVerticalLines
autoResizeMode
protected int autoResizeMode
This mode value determines if table automatically resizes the width the table's
columns to take up the entire width of the table, and how it does the resizing.
autoCreateColumnsFromModel
protected boolean autoCreateColumnsFromModel
The table will query the TableModel to build the default set of columns if this is true.
preferredViewportSize
protected Dimension preferredViewportSize
rowSelectionAllowed
protected boolean rowSelectionAllowed
If this is true, then both a row selection and a column selection can be non-empty at
the same time, the selected cells are the the cells whose row and column are both
selected.
editorComp
protected transient Component editorComp
cellEditor
protected transient TableCellEditor cellEditor
The object that overwrites the screen real estate occupied by the current cell and
allows the user to change those contents.
editingColumn
protected transient int editingColumn
editingRow
protected transient int editingRow
defaultRenderersByColumnClass
protected transient Hashtable defaultRenderersByColumnClass
defaultEditorsByColumnClass
protected transient Hashtable defaultEditorsByColumnClass
A table of objects that display and edit the contents of a cell, indexed by class.
selectionForeground
protected Color selectionForeground
Constructor Detail
JTable
public JTable()
Constructs a default JTable which is initialized with a default data model, a default
column model, and a default selection model.
See Also:
createDefaultDataModel(), createDefaultColumnModel(),
createDefaultSelectionModel()
JTable
public JTable(TableModel dm)
Constructs a JTable which is initialized with dm as the data model, a default column
model, and a default selection model.
Parameters:
dm - The data model for the table
See Also:
createDefaultColumnModel(), createDefaultSelectionModel()
JTable
public JTable(TableModel dm,
TableColumnModel cm)
Constructs a JTable which is initialized with dm as the data model, cm as the column
model, and a default selection model.
Parameters:
dm - The data model for the table
cm - The column model for the table
See Also:
createDefaultSelectionModel()
JTable
public JTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
Constructs a JTable which is initialized with dm as the data model, cm as the column
model, and sm as the selection model. If any of the parameters are null this method
will initialize the table with the corresponding default model. The
autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to
true and the column model is populated with suitable TableColumns for the columns
in dm.
Parameters:
dm - The data model for the table
cm - The column model for the table
sm - The row selection model for the table
See Also:
createDefaultDataModel(), createDefaultColumnModel(),
createDefaultSelectionModel()
JTable
public JTable(int numRows,
int numColumns)
Constructs a JTable with numRows and numColumns of empty cells using the
DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.
Parameters:
numRows - The number of rows the table holds
numColumns - The number of columns the table holds
See Also:
DefaultTableModel
JTable
public JTable(Vector rowData,
Vector columnNames)
Constructs a JTable to display the values in the Vector of Vectors, rowData, with
column names, columnNames. The Vectors contained in rowData should contain the
values for that row. In other words, the value of the cell at row 1, column 5 can be
obtained with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
Parameters:
rowData - The data for the new table
columnNames - Names of each column
JTable
public JTable(Object[][] rowData,
Object[] columnNames)
Constructs a JTable to display the values in the two dimensional array, rowData, with
column names, columnNames. rowData is an Array of rows, so the value of the cell at
row 1, column 5 can be obtained with the following code:
rowData[1][5];
Parameters:
rowData - The data for the new table
columnNames - Names of each column
Method Detail
addNotify
public void addNotify()
Calls configureEnclosingScrollPane.
Overrides:
addNotify in class JComponent
See Also:
configureEnclosingScrollPane()
configureEnclosingScrollPane
protected void configureEnclosingScrollPane()
See Also:
addNotify()
createScrollPaneForTable
public static JScrollPane createScrollPaneForTable(JTable aTable)
setTableHeader
public void setTableHeader(JTableHeader newHeader)
Sets the tableHeader working with this JTable to newHeader. It is legal to have a null
tableHeader.
Parameters:
newHeader - new tableHeader
See Also:
getTableHeader()
getTableHeader
public JTableHeader getTableHeader()
Returns:
the tableHeader working with the receiver
See Also:
#setTableHeader()
setRowHeight
public void setRowHeight(int newHeight)
Parameters:
newRowHeight - new row height
Throws:
IllegalArgumentException - If newRowHeight is less than 1.
See Also:
getRowHeight()
getRowHeight
public int getRowHeight()
Returns the height of a table row in the receiver. The default row height is 16.0.
Returns:
the height of each row in the receiver
See Also:
#setRowHeight()
setRowMargin
public void setRowMargin(int rowMargin)
See Also:
getRowMargin()
getRowMargin
public int getRowMargin()
Gets the amount of emtpy space between rows. Equivalent to:
getIntercellSpacing().height.
See Also:
setRowMargin(int)
setIntercellSpacing
public void setIntercellSpacing(Dimension newSpacing)
Sets the width and height between cells to newSpacing and redisplays the receiver.
Parameters:
newSpacing - The new width and height intercellSpacing
See Also:
getIntercellSpacing()
getIntercellSpacing
public Dimension getIntercellSpacing()
Returns the horizontal and vertical spacing between cells. The default spacing is (3, 2).
Returns:
the horizontal and vertical spacing between cells
See Also:
#setIntercellSpacing()
setGridColor
public void setGridColor(Color newColor)
Sets the color used to draw grid lines to color and redisplays the receiver. The default
color is gray.
Parameters:
color - new color of the grid
Throws:
IllegalArgumentException - if color is null
See Also:
getGridColor()
getGridColor
public Color getGridColor()
Returns the color used to draw grid lines. The default color is gray.
Returns:
the color used to draw grid lines
See Also:
#setGridColor()
setShowGrid
public void setShowGrid(boolean b)
Sets whether the receiver draws grid lines around cells. If flag is true it does; if it is
false it doesn't. There is no getShowGrid() method as the this state is held in two
variables: showHorizontalLines and showVerticalLines each of which may be queried
independently.
Parameters:
flag - true if table view should draw grid lines
See Also:
setShowVerticalLines(boolean), setShowHorizontalLines(boolean)
setShowHorizontalLines
public void setShowHorizontalLines(boolean b)
Sets whether the receiver draws horizontal lines between cells. If flag is true it does; if
it is false it doesn't.
Parameters:
flag - true if table view should draw horizontal lines
See Also:
getShowHorizontalLines(), setShowGrid(boolean), setShowVerticalLines(boolean)
setShowVerticalLines
public void setShowVerticalLines(boolean b)
Sets whether the receiver draws vertical lines between cells. If flag is true it does; if it
is false it doesn't.
Parameters:
flag - true if table view should draw vertical lines
See Also:
getShowVerticalLines(), setShowGrid(boolean), setShowHorizontalLines(boolean)
getShowHorizontalLines
public boolean getShowHorizontalLines()
Returns true if the receiver draws horizontal lines between cells, false if it doesn't. The
default is true.
Returns:
true if the receiver draws horizontal lines between cells, false if it doesn't
See Also:
setShowHorizontalLines(boolean)
getShowVerticalLines
public boolean getShowVerticalLines()
Returns true if the receiver draws vertical lines between cells, false if it doesn't. The
default is true.
Returns:
true if the receiver draws vertical lines between cells, false if it doesn't
See Also:
setShowVerticalLines(boolean)
setAutoResizeMode
public void setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized.
Parameters:
mode - One of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN,
AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN,
AUTO_RESIZE_ALL_COLUMNS
See Also:
getAutoResizeMode(), #sizeColumnsToFit()
getAutoResizeMode
public int getAutoResizeMode()
Returns:
the autoResizeMode of the table
See Also:
#setAutoResizeMode(), #sizeColumnsToFit()
setAutoCreateColumnsFromModel
public void setAutoCreateColumnsFromModel(boolean createColumns)
Parameters:
createColumns - true if JTable should auto create columns
See Also:
getAutoCreateColumnsFromModel(), createDefaultColumnsFromModel()
getAutoCreateColumnsFromModel
public boolean getAutoCreateColumnsFromModel()
Returns whether the table will create default columns from the model. If this is true,
setModel() will clear any existing columns and create new columns from the new
model. Also if the event in the the tableChanged() notification specified the entired
table changed then the columns will be rebuilt. The default is true.
Returns:
the autoCreateColumnsFromModel of the table
See Also:
#setAutoCreateColumnsFromModel(), createDefaultColumnsFromModel()
createDefaultColumnsFromModel
public void createDefaultColumnsFromModel()
This method will create default columns for the table from the data model using the
getColumnCount() and getColumnClass() methods defined in the TableModel interface.
This method will clear any exsiting columns before creating the new columns based
on information from the model.
See Also:
getAutoCreateColumnsFromModel()
setDefaultRenderer
public void setDefaultRenderer(Class columnClass,
TableCellRenderer renderer)
See Also:
getDefaultRenderer(java.lang.Class), setDefaultEditor(java.lang.Class,
com.sun.java.swing.table.TableCellEditor)
getDefaultRenderer
public TableCellRenderer getDefaultRenderer(Class columnClass)
Returns the renderer to be used when no renderer has been set in a TableColumn.
During the rendering of cells the renderer is fetched from a Hashtable of entries
according to the class of the cells in the column. If there is no entry for this
columnClass the method returns the entry for the most specific superclass. The JTable
installs entries for Object, Number and Boolean all which can be modified or replaced.
See Also:
setDefaultRenderer(java.lang.Class, com.sun.java.swing.table.TableCellRenderer),
getColumnClass(int)
setDefaultEditor
public void setDefaultEditor(Class columnClass,
TableCellEditor editor)
Set a default editor to be used if no editor has been set in a TableColumn. If no editing
is required in a table or a particular column in a table use the isCellEditable() method
in the TableModel interface to ensure that the JTable will not start an editor in these
columns.
See Also:
TableModel.isCellEditable(int, int), getDefaultEditor(java.lang.Class),
setDefaultRenderer(java.lang.Class, com.sun.java.swing.table.TableCellRenderer)
getDefaultEditor
public TableCellEditor getDefaultEditor(Class columnClass)
Returns the editor to be used when no editor has been set in a TableColumn. During
the editing of cells the editor is fetched from a Hashtable of entries according to the
class of the cells in the column. If there is no entry for this columnClass the method
returns the entry for the most specific superclass. The JTable installs entries for Object,
Number and Boolean all which can be modified or replaced.
See Also:
setDefaultEditor(java.lang.Class, com.sun.java.swing.table.TableCellEditor),
getColumnClass(int)
setSelectionMode
public void setSelectionMode(int selectionMode)
Sets the table's selection mode to allow only single selections, a single contiguous
interval, or multiple intervals. NOTE:
JTable provides all the methods for handling column and row selection. When setting
states, such as setSelectionMode, it not only updates the mode for the row selection
model but also sets similar values in the selection model of the columnModel. If you
want to have states that is different between rows and columns you can get the
columnModel and change that directly.
Both the row and column selection models for the JTable default to using a
DefaultListSelectionModel so that JTable works the same way as the JList. See
setSelectionMode() in JList for details about the modes.
See Also:
JList.setSelectionMode(int)
setRowSelectionAllowed
public void setRowSelectionAllowed(boolean flag)
See Also:
getRowSelectionAllowed()
getRowSelectionAllowed
public boolean getRowSelectionAllowed()
Returns true if rows can be selected.
Returns:
true if rows can be selected
See Also:
#setRowSelectionAllowed()
setColumnSelectionAllowed
public void setColumnSelectionAllowed(boolean flag)
See Also:
getColumnSelectionAllowed()
getColumnSelectionAllowed
public boolean getColumnSelectionAllowed()
Returns:
true if columns can be selected.
See Also:
setColumnSelectionAllowed(boolean)
setCellSelectionEnabled
public void setCellSelectionEnabled(boolean flag)
Sets whether this table allows both a column selection and a row selection to exist at
the same time. When set, this results in a facility to select a rectangular region of cells
in the display. This flag over-rides the row and column selection modes ensuring that
cell selection is possible whenever this flag is set.
See Also:
getCellSelectionEnabled()
getCellSelectionEnabled
public boolean getCellSelectionEnabled()
Returns:
true if simultaneous row and column selections are allowed
See Also:
setCellSelectionEnabled(boolean)
selectAll
public void selectAll()
If a column is selected, then this selects all columns. Similarly, if a row is selected,
then, this selects all rows. If both a column and a row are selected at the time this
method is invoked, then all columns and rows are selected.
clearSelection
public void clearSelection()
setRowSelectionInterval
public void setRowSelectionInterval(int index0,
int index1)
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
setColumnSelectionInterval
public void setColumnSelectionInterval(int index0,
int index1)
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
addRowSelectionInterval
public void addRowSelectionInterval(int index0,
int index1)
Adds the rows from index0 to index0 inclusive to the current selection.
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
addColumnSelectionInterval
public void addColumnSelectionInterval(int index0,
int index1)
Adds the columns from index0 to index0 inclusive to the current selection.
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
removeRowSelectionInterval
public void removeRowSelectionInterval(int index0,
int index1)
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
removeColumnSelectionInterval
public void removeColumnSelectionInterval(int index0,
int index1)
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
getSelectedRow
public int getSelectedRow()
Returns the index of the last row selected or added to the selection.
Returns:
the index of the last row selected or added to the selection, (lead selection) or -1 if
no row is selected.
See Also:
getSelectedRows()
getSelectedColumn
public int getSelectedColumn()
Returns the index of the last column selected or added to the selection.
Returns:
the index of the last column selected or added to the selection, (lead selection) or
-1 if no column is selected.
See Also:
getSelectedColumns()
getSelectedRows
public int[] getSelectedRows()
Returns the indices of all selected rows.
Returns:
an array of ints containing the indices of all selected rows, or an empty array if
no row is selected.
See Also:
getSelectedRow()
getSelectedColumns
public int[] getSelectedColumns()
Returns:
an array of ints containing the indices of all selected columns, or an empty array
if no column is selected.
See Also:
getSelectedColumn()
getSelectedRowCount
public int getSelectedRowCount()
Returns:
the number of selected rows, 0 if no columns are selected
getSelectedColumnCount
public int getSelectedColumnCount()
Returns:
the number of selected columns, 0 if no columns are selected
isRowSelected
public boolean isRowSelected(int row)
Returns:
true if the row at index row is selected, where 0 is the first row
Throws:
IllegalArgumentException - if row is not in the valid range
isColumnSelected
public boolean isColumnSelected(int column)
Returns true if the column at the specified index is selected
Returns:
true if the column at index column is selected, where 0 is the first column
Throws:
IllegalArgumentException - if column is not in the valid range
isCellSelected
public boolean isCellSelected(int row,
int column)
Returns:
true if the cell at index (row, column) is selected, where the first row and first
column are at index 0
Throws:
IllegalArgumentException - if row or column are not in the valid range
getSelectionForeground
public Color getSelectionForeground()
Returns:
the Color object for the foreground property
See Also:
setSelectionForeground(java.awt.Color), setSelectionBackground(java.awt.Color)
setSelectionForeground
public void setSelectionForeground(Color selectionForeground)
Set the foreground color for selected cells. Cell renderers can use this color to render
text and graphics for selected cells.
The default value of this property is defined by the look and feel implementation.
Parameters:
selectionForeground - the Color to use in the foreground for selected list items
See Also:
getSelectionForeground(), setSelectionBackground(java.awt.Color),
Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color),
Component.setFont(java.awt.Font)
getSelectionBackground
public Color getSelectionBackground()
Returns the background color for selected cells.
Returns:
the Color used for the background of selected list items
See Also:
setSelectionBackground(java.awt.Color), setSelectionForeground(java.awt.Color)
setSelectionBackground
public void setSelectionBackground(Color selectionBackground)
Set the background color for selected cells. Cell renderers can use this color to the fill
selected cells.
The default value of this property is defined by the look and feel implementation.
Parameters:
selectionBackground - the Color to use for the background of selected cells
See Also:
getSelectionBackground(), setSelectionForeground(java.awt.Color),
Component.setForeground(java.awt.Color), Component.setBackground(java.awt.Color),
Component.setFont(java.awt.Font)
getColumn
public TableColumn getColumn(Object identifier)
Returns the TableColumn object for the column in the table whose identifier is equal
to identifier, when compared using equals().
Parameters:
identifier - the identifier object
Returns:
the TableColumn object with matching identifier
Throws:
IllegalArgumentException - if identifier is null or no TableColumn has this
identifier
convertColumnIndexToModel
public int convertColumnIndexToModel(int viewColumnIndex)
Return the index of the column in the model whose data is being displayed in the
column viewColumnIndex in the display. Returns viewColumnIndex unchanged when
viewColumnIndex is less than zero.
See Also:
convertColumnIndexToView(int)
convertColumnIndexToView
public int convertColumnIndexToView(int modelColumnIndex)
Return the index of the column in the view which is displaying the data from the
column modelColumnIndex in the model. Returns -1 if this column is not being
displayed. Returns modelColumnIndex unchanged when modelColumnIndex is less
than zero.
See Also:
convertColumnIndexToModel(int)
getRowCount
public int getRowCount()
See Also:
getColumnCount()
getColumnCount
public int getColumnCount()
Returns the number of columns in the column model, note this may be different to the
number of columns in the table model.
Returns:
the number of columns in the table
See Also:
getRowCount()
getColumnName
public String getColumnName(int column)
Returns:
the name of the column at position column in the view where the first column is
column 0.
getColumnClass
public Class getColumnClass(int column)
Returns:
the type of the column at position column in the view where the first column is
column 0.
getValueAt
public Object getValueAt(int row,
int column)
NOTE: The column is specified in the table view's display order, and not in the
TableModel's column order. This is an important distinction because as the user
rearranges the columns in the table, what is at column 2 changes. Meanwhile the
user's actions never affect the model's column ordering.
Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
the Object at the specified cell
setValueAt
public void setValueAt(Object aValue,
int row,
int column)
Sets the value for the cell at row and column. aValue is the new value.
Parameters:
aValue - the new value
row - the row whose value is to be changed
column - the column whose value is to be changed
See Also:
#getValueAt()
isCellEditable
public boolean isCellEditable(int row,
int column)
Returns true if the cell at row and column is editable. Otherwise, setValueAt() on the
cell will not change the value of that cell.
Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
true if the cell is editable.
See Also:
#setValueAt()
addColumn
public void addColumn(TableColumn aColumn)
Appends aColumn to the end of the array of columns held by the JTable's column
model. If the header value of aColumn is null, sets the header value of aColumn to the
name returned by getModel().getColumnName().
To add a column to the JTable to display the modelColumn'th column of data in the
model, with a given width, cellRenderer and cellEditor you can use:
[All of the other constructors in the TableColumn can be used in place of this one.] The
model column is stored inside the TableColumn and is used during rendering and
editing to locate the appropriate data values in the model. The model column does not
change when columns are reordered in the view.
Parameters:
aColumn - The TableColumn to be added
See Also:
removeColumn(com.sun.java.swing.table.TableColumn)
removeColumn
public void removeColumn(TableColumn aColumn)
Removes aColumn from the JTable's array of columns. Note: this method does not
remove the column of data from the model it just removes the TableColumn that was
displaying it.
Parameters:
aColumn - The TableColumn to be removed
See Also:
addColumn(com.sun.java.swing.table.TableColumn)
moveColumn
public void moveColumn(int column,
int targetColumn)
Moves the column column to the position currently occupied by the column
targetColumn. The old column at targetColumn is shifted left or right to make room.
Parameters:
column - the index of column to be moved
targetColumn - the new index of the column
columnAtPoint
public int columnAtPoint(Point point)
Returns the index of the column that point lies in, or -1 if it lies outside the receiver's
bounds.
Returns:
the index of the column that point lies in, or -1 if it lies outside the receiver's
bounds
See Also:
rowAtPoint(java.awt.Point)
rowAtPoint
public int rowAtPoint(Point point)
Returns the index of the row that point lies in, or -1 if is not in the range [0,
getRowCount()-1].
Returns:
the index of the row that point lies in, or -1 if it is not in the range [0,
getRowCount()-1]
See Also:
#columnAtPoint()
getCellRect
public Rectangle getCellRect(int row,
int column,
boolean includeSpacing)
Returns a rectangle locating the cell that lies at the intersection of row and column. If
includeSpacing is true then the value returned includes the intercellSpacing margin. If
it is false, then the returned rect is inset by half of intercellSpacing. (This is the true
frame of the cell)
Parameters:
row - the row to compute
column - the column to compute
includeSpacing - if true, the rect returned will include the correct intercellSpacing
Returns:
the rectangle containing the cell at index row,column
Throws:
IllegalArgumentException - If row or column are not in the valid range.
setBounds
public void setBounds(int x,
int y,
int width,
int height)
Overrides:
setBounds in class Component
sizeColumnsToFit
public void sizeColumnsToFit(boolean lastColumnOnly)
See Also:
#sizeColumnsToFit()
sizeColumnsToFit
public void sizeColumnsToFit(int resizingColumn)
This method will resize one or more ot the columns in the table so that the total width
of all of the JTable's columns will be equal to the width of the table. The auto-resize
modes govern the way that the extra (or defecit) space is distributed amongst the
availible columns.
Note: In all of the other modes, setBounds() operations on the JTable - most often
caused by the resizing of an enclosing window - result in this method being called
with resizingColumn set to -1. This means that resizing has taken place 'outside'
the JTable and the change - or 'delta' - should be distributed to all of the columns
regardless of the JTable's autoResizeMode mode.
When columns are resized individually, for example by mouse events in the
JTableHeader, the following modes are used to determine which columns should
absorb the changes.
Note: When the JTable makes adjustments to the widths of the columns it respects
their minimum and maximum values absolutely. It is therefore possible that, even
after this method is called, the total width of the columns is still not equal to the width
of the table. When this happens the JTable does not put itself in AUTO_RESIZE_OFF
mode to bring up a ScrollBar, or break other commitments of its current auto-resize
mode - instead it allows its bounds to be set larger (or smaller) than the total of the
column minima or maxima, meaning, either that there will not be enough room to
display all of the columns, or that the columns will not fill the JTable's bounds. These
respectively, result in the clipping of some columns or an area being painted in the
JTable's background color during painting.
Parameters:
resizingColumn - The column whose resizing made this adjustment necessary, -1 if
there is no such column.
See Also:
TableColumn.setWidth(int)
getToolTipText
public String getToolTipText(MouseEvent event)
Overrides JComponent's setToolTipText method to allow use of the renderer's tips (if
the renderer has text set).
NOTE: For JTable to properly display tooltips of its renderers JTable must be a
registered component with the ToolTipManager. This is done automatically in
initializeLocalVars(), but if at a later point JTable is told setToolTipText(null) it will
unregister the table component, and no tips from renderers will display anymore.
Overrides:
getToolTipText in class JComponent
See Also:
JComponent.getToolTipText()
editCellAt
public boolean editCellAt(int row,
int column)
Programmatically starts editing the cell at row and column, if the cell is editable.
Parameters:
row - the row to be edited
column - the column to be edited
Returns:
false if for any reason the cell cannot be edited.
Throws:
IllegalArgumentException - If row or column are not in the valid range
editCellAt
public boolean editCellAt(int row,
int column,
EventObject e)
Programmatically starts editing the cell at row and column, if the cell is editable. To
prevent the JTable from editing a particular table, column or cell value, return false
from the isCellEditable() method in the TableModel interface.
Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell
Returns:
false if for any reason the cell cannot be edited.
Throws:
IllegalArgumentException - If row or column are not in the valid range
isEditing
public boolean isEditing()
Returns true is the table is editing a cell.
Returns:
true is the table is editing a cell
See Also:
#editingColumn(), #editingRow()
getEditorComponent
public Component getEditorComponent()
If the receiver is currently editing this will return the Component that was returned
from the CellEditor.
Returns:
Component handling editing session
getEditingColumn
public int getEditingColumn()
Returns:
the index of the column being edited
See Also:
#editingRow()
getEditingRow
public int getEditingRow()
Returns:
the index of the row being edited
See Also:
#editingColumn()
getUI
public TableUI getUI()
Returns:
the TableUI object that renders this component
setUI
public void setUI(TableUI ui)
Sets the L&F object that renders this component.
Parameters:
ui - the TableUI L&F object
See Also:
UIDefaults.getUI(com.sun.java.swing.JComponent)
updateUI
public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI
object with the latest version from the UIManager.
Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()
getUIClassID
public String getUIClassID()
Returns the name of the L&F class that renders this component.
Returns:
"TableUI"
Overrides:
getUIClassID in class JComponent
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(com.sun.java.swing.JComponent)
setModel
public void setModel(TableModel newModel)
Sets the data model for this table to newModel and registers with for listner
notifications from the new data model.
Parameters:
newModel - the new data source for this table
Throws:
IllegalArgumentException - if newModel is null
See Also:
getModel()
getModel
public TableModel getModel()
Returns the TableModel that provides the data displayed by the receiver.
Returns:
the object that provides the data displayed by the receiver
See Also:
#setModel()
setColumnModel
public void setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers with for listner
notifications from the new column model. Also sets the column model of the
JTableHeader to newModel.
Parameters:
newModel - the new data source for this table
Throws:
IllegalArgumentException - if newModel is null
See Also:
getColumnModel()
getColumnModel
public TableColumnModel getColumnModel()
Returns the TableColumnModel that contains all column inforamtion of this table.
Returns:
the object that provides the column state of the table
See Also:
#setColumnModel()
setSelectionModel
public void setSelectionModel(ListSelectionModel newModel)
Sets the row selection model for this table to newModel and registers with for listner
notifications from the new selection model.
Parameters:
newModel - the new selection model
Throws:
IllegalArgumentException - if newModel is null
See Also:
getSelectionModel()
getSelectionModel
public ListSelectionModel getSelectionModel()
Returns:
the object that provides row selection state. Or null if row selection is not
allowed.
See Also:
#setSelectionModel()
tableChanged
public void tableChanged(TableModelEvent e)
Specified by:
tableChanged in interface TableModelListener
columnAdded
public void columnAdded(TableColumnModelEvent e)
Specified by:
columnAdded in interface TableColumnModelListener
See Also:
TableColumnModelListener
columnRemoved
public void columnRemoved(TableColumnModelEvent e)
Specified by:
columnRemoved in interface TableColumnModelListener
See Also:
TableColumnModelListener
columnMoved
public void columnMoved(TableColumnModelEvent e)
Specified by:
columnMoved in interface TableColumnModelListener
See Also:
TableColumnModelListener
columnMarginChanged
public void columnMarginChanged(ChangeEvent e)
Specified by:
columnMarginChanged in interface TableColumnModelListener
See Also:
TableColumnModelListener
columnSelectionChanged
public void columnSelectionChanged(ListSelectionEvent e)
Specified by:
columnSelectionChanged in interface TableColumnModelListener
See Also:
TableColumnModelListener
valueChanged
public void valueChanged(ListSelectionEvent e)
Invoked when the selection changes -- repaints to show the new selection.
Specified by:
valueChanged in interface ListSelectionListener
See Also:
ListSelectionListener
editingStopped
public void editingStopped(ChangeEvent e)
Invoked when editing is finished. The changes are saved, the editor object is discarded,
and the cell is rendered once again.
Specified by:
editingStopped in interface CellEditorListener
See Also:
CellEditorListener
editingCanceled
public void editingCanceled(ChangeEvent e)
Invoked when editing is canceled. The editor object is discarded and the cell is
rendered once again.
Specified by:
editingCanceled in interface CellEditorListener
See Also:
CellEditorListener
setPreferredScrollableViewportSize
public void setPreferredScrollableViewportSize(Dimension size)
Parameters:
size - a Dimension object specifying the preferredSize of a JViewport whose view
is this table
See Also:
Scrollable.getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
public Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface Scrollable
Returns:
a Dimension object containing the preferredSize of the JViewport which displays
this table
See Also:
Scrollable.getPreferredScrollableViewportSize()
getScrollableUnitIncrement
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
Returns the scroll increment that completely exposes one new row or column
(depending on the orientation).
This method is called each time the user requests a unit scroll.
Specified by:
getScrollableUnitIncrement in interface Scrollable
Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "unit" increment for scrolling in the specified direction
See Also:
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
getScrollableBlockIncrement
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
Specified by:
getScrollableBlockIncrement in interface Scrollable
Returns:
The visibleRect.height or visibleRect.width per the orientation.
See Also:
Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not determine the width
of the table.
Specified by:
getScrollableTracksViewportWidth in interface Scrollable
Returns:
false
See Also:
Scrollable.getScrollableTracksViewportWidth()
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not determine the height
of the table.
Specified by:
getScrollableTracksViewportHeight in interface Scrollable
Returns:
false
See Also:
Scrollable.getScrollableTracksViewportHeight()
createDefaultRenderers
protected void createDefaultRenderers()
createDefaultEditors
protected void createDefaultEditors()
Creates default cell editors for Objects, numbers, and boolean values.
initializeLocalVars
protected void initializeLocalVars()
createDefaultDataModel
protected TableModel createDefaultDataModel()
Returns the default table model object which is a DefaultTableModel. Subclass can
override this method to return a different table model object.
Returns:
the default table model object
createDefaultColumnModel
protected TableColumnModel createDefaultColumnModel()
Returns:
the default column model object
createDefaultSelectionModel
protected ListSelectionModel createDefaultSelectionModel()
Returns:
the default selection model object
createDefaultTableHeader
protected JTableHeader createDefaultTableHeader()
Returns the default table header object which is a JTableHeader. Subclass can override
this method to return a different table header object
Returns:
the default table header object
resizeAndRepaint
protected void resizeAndRepaint()
Equivalent to revalidate().
getCellEditor
public TableCellEditor getCellEditor()
Returns:
the TableCellEditor that does the editing
See Also:
cellEditor
setCellEditor
public void setCellEditor(TableCellEditor anEditor)
Parameters:
anEditor - the TableCellEditor that does the editing
See Also:
cellEditor
setEditingColumn
public void setEditingColumn(int aColumn)
See Also:
editingColumn
setEditingRow
public void setEditingRow(int aRow)
See Also:
editingRow
getCellRenderer
public TableCellRenderer getCellRenderer(int row,
int column)
Return an appropriate renderer for the cell specified by this this row and column. If
the TableColumn for this column has a non-null renderer, return that. If not, find the
class of the data in this column (using getColumnClass()) and return the default
renderer for this type of data.
Parameters:
row - the row of the cell to render, where 0 is the first
column - the column of the cell to render, where 0 is the first
prepareRenderer
public Component prepareRenderer(TableCellRenderer renderer,
int row,
int column)
Prepares the specified renderer with an appropriate value from the dataModel, and an
appropriate selection value from the selection models.
Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first
column - the column of the cell to render, where 0 is the first
getCellEditor
public TableCellEditor getCellEditor(int row,
int column)
Return an appropriate editor for the cell specified by this this row and column. If the
TableColumn for this column has a non-null editor, return that. If not, find the class of
the data in this column (using getColumnClass()) and return the default editor for this
type of data.
Parameters:
row - the row of the cell to edit, where 0 is the first
column - the column of the cell to edit, where 0 is the first
prepareEditor
public Component prepareEditor(TableCellEditor editor,
int row,
int column)
Prepares the specified editor using the value at the specified cell.
Parameters:
editor - the TableCellEditor to set up
row - the row of the cell to edit, where 0 is the first
column - the column of the cell to edit, where 0 is the first
removeEditor
public void removeEditor()
Discard the editor object and return the real estate it used to cell rendering.
getAccessibleContext
public AccessibleContext getAccessibleContext()