Java Doc for TableColumn.java in  » 6.0-JDK-Core » swing » javax » swing » table » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.table 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.swing.table.TableColumn

TableColumn
public class TableColumn extends Object implements Serializable(Code)
A TableColumn represents all the attributes of a column in a JTable, such as width, resizibility, minimum and maximum width. In addition, the TableColumn provides slots for a renderer and an editor that can be used to display and edit the values in this column.

It is also possible to specify renderers and editors on a per type basis rather than a per column basis - see the setDefaultRenderer method in the JTable class. This default mechanism is only used when the renderer (or editor) in the TableColumn is null.

The TableColumn stores the link between the columns in the JTable and the columns in the TableModel. The modelIndex is the column in the TableModel, which will be queried for the data values for the cells in this column. As the column moves around in the view this modelIndex does not change.

Note: Some implementations may assume that all TableColumnModels are unique, therefore we would recommend that the same TableColumn instance not be added more than once to a TableColumnModel. To show TableColumns with the same column of data from the model, create a new instance with the same modelIndex.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder .
version:
   1.69 05/05/07
author:
   Alan Chung
author:
   Philip Milne
See Also:   javax.swing.table.TableColumnModel
See Also:   javax.swing.table.DefaultTableColumnModel
See Also:   javax.swing.table.JTableHeader.getDefaultRenderer
See Also:   JTable.getDefaultRenderer(Class)
See Also:   JTable.getDefaultEditor(Class)
See Also:   JTable.getCellRenderer(intint)
See Also:   JTable.getCellEditor(intint)



Field Summary
final public static  StringCELL_RENDERER_PROPERTY
     Obsolete as of Java 2 platform v1.3.
final public static  StringCOLUMN_WIDTH_PROPERTY
     Obsolete as of Java 2 platform v1.3.
final public static  StringHEADER_RENDERER_PROPERTY
     Obsolete as of Java 2 platform v1.3.
final public static  StringHEADER_VALUE_PROPERTY
     Obsolete as of Java 2 platform v1.3.
protected  TableCellEditorcellEditor
     The editor used to edit the data cells of the column.
protected  TableCellRenderercellRenderer
     The renderer used to draw the data cells of the column.
protected  TableCellRendererheaderRenderer
     The renderer used to draw the header of the column.
protected  ObjectheaderValue
     The header value of the column.
protected  Objectidentifier
     This object is not used internally by the drawing machinery of the JTable; identifiers may be set in the TableColumn as as an optional way to tag and locate table columns.
protected  booleanisResizable
     If true, the user is allowed to resize the column; the default is true.
protected  intmaxWidth
     The maximum width of the column.
protected  intminWidth
     The minimum width of the column.
protected  intmodelIndex
     The index of the column in the model which is to be displayed by this TableColumn.
protected transient  intresizedPostingDisableCount
     This field was not used in previous releases and there are currently no plans to support it in the future.
protected  intwidth
     The width of the column.

Constructor Summary
public  TableColumn()
     Cover method, using a default model index of 0, default width of 75, a null renderer and a null editor.
public  TableColumn(int modelIndex)
     Cover method, using a default width of 75, a null renderer and a null editor.
public  TableColumn(int modelIndex, int width)
     Cover method, using a null renderer and a null editor.
public  TableColumn(int modelIndex, int width, TableCellRenderer cellRenderer, TableCellEditor cellEditor)
     Creates and initializes an instance of TableColumn with the specified model index, width, cell renderer, and cell editor; all TableColumn constructors delegate to this one. The value of width is used for both the initial and preferred width; if width is negative, they're set to 0. The minimum width is set to 15 unless the initial width is less, in which case the minimum width is set to the initial width.

When the cellRenderer or cellEditor parameter is null, a default value provided by the JTable getDefaultRenderer or getDefaultEditor method, respectively, is used to provide defaults based on the type of the data in this column.


Method Summary
public synchronized  voidaddPropertyChangeListener(PropertyChangeListener listener)
     Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

A PropertyChangeEvent will get fired in response to an explicit call to setFont, setBackground, or setForeground on the current component.

protected  TableCellRenderercreateDefaultHeaderRenderer()
     As of Java 2 platform v1.3, this method is not called by the TableColumn constructor.
public  voiddisableResizedPosting()
     This field was not used in previous releases and there are currently no plans to support it in the future.
public  voidenableResizedPosting()
     This field was not used in previous releases and there are currently no plans to support it in the future.
public  TableCellEditorgetCellEditor()
     Returns the TableCellEditor used by the JTable to edit values for this column.
public  TableCellRenderergetCellRenderer()
     Returns the TableCellRenderer used by the JTable to draw values for this column.
public  TableCellRenderergetHeaderRenderer()
     Returns the TableCellRenderer used to draw the header of the TableColumn.
public  ObjectgetHeaderValue()
     Returns the Object used as the value for the header renderer.
public  ObjectgetIdentifier()
     Returns the identifier object for this column.
public  intgetMaxWidth()
     Returns the maximum width for the TableColumn.
public  intgetMinWidth()
     Returns the minimum width for the TableColumn.
public  intgetModelIndex()
     Returns the model index for this column.
public  intgetPreferredWidth()
     Returns the preferred width of the TableColumn.
public synchronized  PropertyChangeListener[]getPropertyChangeListeners()
     Returns an array of all the PropertyChangeListeners added to this TableColumn with addPropertyChangeListener().
public  booleangetResizable()
     Returns true if the user is allowed to resize the TableColumn's width, false otherwise.
public  intgetWidth()
     Returns the width of the TableColumn.
public synchronized  voidremovePropertyChangeListener(PropertyChangeListener listener)
     Removes a PropertyChangeListener from the listener list.
public  voidsetCellEditor(TableCellEditor cellEditor)
     Sets the editor to used by when a cell in this column is edited.
public  voidsetCellRenderer(TableCellRenderer cellRenderer)
     Sets the TableCellRenderer used by JTable to draw individual values for this column.
public  voidsetHeaderRenderer(TableCellRenderer headerRenderer)
     Sets the TableCellRenderer used to draw the TableColumn's header to headerRenderer.
public  voidsetHeaderValue(Object headerValue)
     Sets the Object whose string representation will be used as the value for the headerRenderer.
public  voidsetIdentifier(Object identifier)
     Sets the TableColumn's identifier to anIdentifier.
public  voidsetMaxWidth(int maxWidth)
     Sets the TableColumn's maximum width to maxWidth or, if maxWidth is less than the minimum width, to the minimum width.
public  voidsetMinWidth(int minWidth)
     Sets the TableColumn's minimum width to minWidth, adjusting the new minimum width if necessary to ensure that 0 <= minWidth <= maxWidth.
public  voidsetModelIndex(int modelIndex)
     Sets the model index for this column.
public  voidsetPreferredWidth(int preferredWidth)
     Sets this column's preferred width to preferredWidth.
public  voidsetResizable(boolean isResizable)
     Sets whether this column can be resized.
public  voidsetWidth(int width)
     This method should not be used to set the widths of columns in the JTable, use setPreferredWidth instead. Like a layout manager in the AWT, the JTable adjusts a column's width automatically whenever the table itself changes size, or a column's preferred width is changed.
public  voidsizeWidthToFit()
     Resizes the TableColumn to fit the width of its header cell. This method does nothing if the header renderer is null (the default case).

Field Detail
CELL_RENDERER_PROPERTY
final public static String CELL_RENDERER_PROPERTY(Code)
Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties.



COLUMN_WIDTH_PROPERTY
final public static String COLUMN_WIDTH_PROPERTY(Code)
Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties.



HEADER_RENDERER_PROPERTY
final public static String HEADER_RENDERER_PROPERTY(Code)
Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties.



HEADER_VALUE_PROPERTY
final public static String HEADER_VALUE_PROPERTY(Code)
Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties.



cellEditor
protected TableCellEditor cellEditor(Code)
The editor used to edit the data cells of the column.



cellRenderer
protected TableCellRenderer cellRenderer(Code)
The renderer used to draw the data cells of the column.



headerRenderer
protected TableCellRenderer headerRenderer(Code)
The renderer used to draw the header of the column.



headerValue
protected Object headerValue(Code)
The header value of the column.



identifier
protected Object identifier(Code)
This object is not used internally by the drawing machinery of the JTable; identifiers may be set in the TableColumn as as an optional way to tag and locate table columns. The table package does not modify or invoke any methods in these identifier objects other than the equals method which is used in the getColumnIndex() method in the DefaultTableColumnModel.



isResizable
protected boolean isResizable(Code)
If true, the user is allowed to resize the column; the default is true.



maxWidth
protected int maxWidth(Code)
The maximum width of the column.



minWidth
protected int minWidth(Code)
The minimum width of the column.



modelIndex
protected int modelIndex(Code)
The index of the column in the model which is to be displayed by this TableColumn. As columns are moved around in the view modelIndex remains constant.



resizedPostingDisableCount
protected transient int resizedPostingDisableCount(Code)
This field was not used in previous releases and there are currently no plans to support it in the future.



width
protected int width(Code)
The width of the column.




Constructor Detail
TableColumn
public TableColumn()(Code)
Cover method, using a default model index of 0, default width of 75, a null renderer and a null editor. This method is intended for serialization.
See Also:   TableColumn.TableColumn(int,int,TableCellRenderer,TableCellEditor)



TableColumn
public TableColumn(int modelIndex)(Code)
Cover method, using a default width of 75, a null renderer and a null editor.
See Also:   TableColumn.TableColumn(int,int,TableCellRenderer,TableCellEditor)



TableColumn
public TableColumn(int modelIndex, int width)(Code)
Cover method, using a null renderer and a null editor.
See Also:   TableColumn.TableColumn(int,int,TableCellRenderer,TableCellEditor)



TableColumn
public TableColumn(int modelIndex, int width, TableCellRenderer cellRenderer, TableCellEditor cellEditor)(Code)
Creates and initializes an instance of TableColumn with the specified model index, width, cell renderer, and cell editor; all TableColumn constructors delegate to this one. The value of width is used for both the initial and preferred width; if width is negative, they're set to 0. The minimum width is set to 15 unless the initial width is less, in which case the minimum width is set to the initial width.

When the cellRenderer or cellEditor parameter is null, a default value provided by the JTable getDefaultRenderer or getDefaultEditor method, respectively, is used to provide defaults based on the type of the data in this column. This column-centric rendering strategy can be circumvented by overriding the getCellRenderer methods in JTable.
Parameters:
  modelIndex - the index of the column in the model that supplies the data for this column in the table;the model index remains the sameeven when columns are reordered in the view
Parameters:
  width - this column's preferred width and initial width
Parameters:
  cellRenderer - the object used to render values in this column
Parameters:
  cellEditor - the object used to edit values in this column
See Also:   TableColumn.getMinWidth()
See Also:   JTable.getDefaultRenderer(Class)
See Also:   JTable.getDefaultEditor(Class)
See Also:   JTable.getCellRenderer(intint)
See Also:   JTable.getCellEditor(intint)





Method Detail
addPropertyChangeListener
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)(Code)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

A PropertyChangeEvent will get fired in response to an explicit call to setFont, setBackground, or setForeground on the current component. Note that if the current component is inheriting its foreground, background, or font from its container, then no event will be fired in response to a change in the inherited property.
Parameters:
  listener - the listener to be added




createDefaultHeaderRenderer
protected TableCellRenderer createDefaultHeaderRenderer()(Code)
As of Java 2 platform v1.3, this method is not called by the TableColumn constructor. Previously this method was used by the TableColumn to create a default header renderer. As of Java 2 platform v1.3, the default header renderer is null. JTableHeader now provides its own shared default renderer, just as the JTable does for its cell renderers. the default header renderer
See Also:   javax.swing.table.JTableHeader.createDefaultRenderer



disableResizedPosting
public void disableResizedPosting()(Code)
This field was not used in previous releases and there are currently no plans to support it in the future.



enableResizedPosting
public void enableResizedPosting()(Code)
This field was not used in previous releases and there are currently no plans to support it in the future.



getCellEditor
public TableCellEditor getCellEditor()(Code)
Returns the TableCellEditor used by the JTable to edit values for this column. When the cellEditor is null, the JTable uses a default editor based on the class of the cells in that column. The default value for a cellEditor is null. the cellEditor property
See Also:   TableColumn.setCellEditor
See Also:   JTable.setDefaultEditor



getCellRenderer
public TableCellRenderer getCellRenderer()(Code)
Returns the TableCellRenderer used by the JTable to draw values for this column. The cellRenderer of the column not only controls the visual look for the column, but is also used to interpret the value object supplied by the TableModel. When the cellRenderer is null, the JTable uses a default renderer based on the class of the cells in that column. The default value for a cellRenderer is null. the cellRenderer property
See Also:   TableColumn.setCellRenderer
See Also:   JTable.setDefaultRenderer



getHeaderRenderer
public TableCellRenderer getHeaderRenderer()(Code)
Returns the TableCellRenderer used to draw the header of the TableColumn. When the headerRenderer is null, the JTableHeader uses its defaultRenderer. The default value for a headerRenderer is null. the headerRenderer property
See Also:   TableColumn.setHeaderRenderer
See Also:   TableColumn.setHeaderValue
See Also:   
See Also:   javax.swing.table.JTableHeader.getDefaultRenderer



getHeaderValue
public Object getHeaderValue()(Code)
Returns the Object used as the value for the header renderer. the headerValue property
See Also:   TableColumn.setHeaderValue



getIdentifier
public Object getIdentifier()(Code)
Returns the identifier object for this column. Note identifiers are not used by JTable, they are purely a convenience for external use. If the identifier is null, getIdentifier() returns getHeaderValue as a default. the identifier property
See Also:   TableColumn.setIdentifier



getMaxWidth
public int getMaxWidth()(Code)
Returns the maximum width for the TableColumn. The TableColumn's width can't be made larger than this either by the user or programmatically. The default maxWidth is Integer.MAX_VALUE. the maxWidth property
See Also:   TableColumn.setMaxWidth



getMinWidth
public int getMinWidth()(Code)
Returns the minimum width for the TableColumn. The TableColumn's width can't be made less than this either by the user or programmatically. the minWidth property
See Also:   TableColumn.setMinWidth
See Also:   TableColumn.TableColumn(int,int,TableCellRenderer,TableCellEditor)



getModelIndex
public int getModelIndex()(Code)
Returns the model index for this column. the modelIndex property



getPreferredWidth
public int getPreferredWidth()(Code)
Returns the preferred width of the TableColumn. The default preferred width is 75. the preferredWidth property
See Also:   TableColumn.setPreferredWidth



getPropertyChangeListeners
public synchronized PropertyChangeListener[] getPropertyChangeListeners()(Code)
Returns an array of all the PropertyChangeListeners added to this TableColumn with addPropertyChangeListener(). all of the PropertyChangeListeners added or an emptyarray if no listeners have been added
since:
   1.4



getResizable
public boolean getResizable()(Code)
Returns true if the user is allowed to resize the TableColumn's width, false otherwise. You can change the width programmatically regardless of this setting. The default is true. the isResizable property
See Also:   TableColumn.setResizable



getWidth
public int getWidth()(Code)
Returns the width of the TableColumn. The default width is 75. the width property
See Also:   TableColumn.setWidth



removePropertyChangeListener
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)(Code)
Removes a PropertyChangeListener from the listener list. The PropertyChangeListener to be removed was registered for all properties.
Parameters:
  listener - the listener to be removed



setCellEditor
public void setCellEditor(TableCellEditor cellEditor)(Code)
Sets the editor to used by when a cell in this column is edited.
Parameters:
  cellEditor - the new cellEditor
See Also:   TableColumn.getCellEditor



setCellRenderer
public void setCellRenderer(TableCellRenderer cellRenderer)(Code)
Sets the TableCellRenderer used by JTable to draw individual values for this column.
Parameters:
  cellRenderer - the new cellRenderer
See Also:   TableColumn.getCellRenderer



setHeaderRenderer
public void setHeaderRenderer(TableCellRenderer headerRenderer)(Code)
Sets the TableCellRenderer used to draw the TableColumn's header to headerRenderer.

It is the header renderers responsibility to render the sorting indicator. If you are using sorting and specify a renderer your renderer must render the sorting indication.
Parameters:
  headerRenderer - the new headerRenderer
See Also:   TableColumn.getHeaderRenderer




setHeaderValue
public void setHeaderValue(Object headerValue)(Code)
Sets the Object whose string representation will be used as the value for the headerRenderer. When the TableColumn is created, the default headerValue is null.
Parameters:
  headerValue - the new headerValue
See Also:   TableColumn.getHeaderValue



setIdentifier
public void setIdentifier(Object identifier)(Code)
Sets the TableColumn's identifier to anIdentifier.

Note: identifiers are not used by the JTable, they are purely a convenience for the external tagging and location of columns.
Parameters:
  identifier - an identifier for this column
See Also:   TableColumn.getIdentifier




setMaxWidth
public void setMaxWidth(int maxWidth)(Code)
Sets the TableColumn's maximum width to maxWidth or, if maxWidth is less than the minimum width, to the minimum width.

If the value of the width or preferredWidth property is more than the new maximum width, this method sets that property to the new maximum width.
Parameters:
  maxWidth - the new maximum width
See Also:   TableColumn.getMaxWidth
See Also:   TableColumn.setPreferredWidth
See Also:   TableColumn.setMinWidth




setMinWidth
public void setMinWidth(int minWidth)(Code)
Sets the TableColumn's minimum width to minWidth, adjusting the new minimum width if necessary to ensure that 0 <= minWidth <= maxWidth. For example, if the minWidth argument is negative, this method sets the minWidth property to 0.

If the value of the width or preferredWidth property is less than the new minimum width, this method sets that property to the new minimum width.
Parameters:
  minWidth - the new minimum width
See Also:   TableColumn.getMinWidth
See Also:   TableColumn.setPreferredWidth
See Also:   TableColumn.setMaxWidth




setModelIndex
public void setModelIndex(int modelIndex)(Code)
Sets the model index for this column. The model index is the index of the column in the model that will be displayed by this TableColumn. As the TableColumn is moved around in the view the model index remains constant.
Parameters:
  modelIndex - the new modelIndex



setPreferredWidth
public void setPreferredWidth(int preferredWidth)(Code)
Sets this column's preferred width to preferredWidth. If preferredWidth exceeds the minimum or maximum width, it is adjusted to the appropriate limiting value.

For details on how the widths of columns in the JTable (and JTableHeader) are calculated from the preferredWidth, see the doLayout method in JTable.
Parameters:
  preferredWidth - the new preferred width
See Also:   TableColumn.getPreferredWidth
See Also:   JTable.doLayout




setResizable
public void setResizable(boolean isResizable)(Code)
Sets whether this column can be resized.
Parameters:
  isResizable - if true, resizing is allowed; otherwise false
See Also:   TableColumn.getResizable



setWidth
public void setWidth(int width)(Code)
This method should not be used to set the widths of columns in the JTable, use setPreferredWidth instead. Like a layout manager in the AWT, the JTable adjusts a column's width automatically whenever the table itself changes size, or a column's preferred width is changed. Setting widths programmatically therefore has no long term effect.

This method sets this column's width to width. If width exceeds the minimum or maximum width, it is adjusted to the appropriate limiting value.
Parameters:
  width - the new width
See Also:   TableColumn.getWidth
See Also:   TableColumn.setMinWidth
See Also:   TableColumn.setMaxWidth
See Also:   TableColumn.setPreferredWidth
See Also:   JTable.doLayout




sizeWidthToFit
public void sizeWidthToFit()(Code)
Resizes the TableColumn to fit the width of its header cell. This method does nothing if the header renderer is null (the default case). Otherwise, it sets the minimum, maximum and preferred widths of this column to the widths of the minimum, maximum and preferred sizes of the Component delivered by the header renderer. The transient "width" property of this TableColumn is also set to the preferred width. Note this method is not used internally by the table package.
See Also:   TableColumn.setPreferredWidth



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.