The JTable is used to display and edit regular two-dimensional tables of cells. See How to Use Tables in The Java Tutorial for task-oriented documentation and examples of using JTable.

The JTable has many facilities that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily. For example, to set up a table with 10 rows and 10 columns of numbers:

      TableModel dataModel = new AbstractTableModel() {
          public int getColumnCount() { return 10; }
          public int getRowCount() { return 10;}
          public Object getValueAt(int row, int col) { return new Integer(row*col); }
      };
      JTable table = new JTable(dataModel);
      JScrollPane scrollpane = new JScrollPane(table);
 

Note that if you wish to use a JTable in a standalone view (outside of a JScrollPane) and want the header displayed, you can get it using #getTableHeader and display it separately.

When designing applications that use the JTable it is worth paying close attention to the data structures that will represent the table's data. The DefaultTableModel is a model implementation that uses a Vector of Vectors of Objects to store the cell values. As well as copying the data from an application into the DefaultTableModel, it is also possible to wrap the data in the methods of the TableModel interface so that the data can be passed to the JTable directly, as in the example above. This often results in more efficient applications because the model is free to choose the internal representation that best suits the data. A good rule of thumb for deciding whether to use the AbstractTableModel or the DefaultTableModel is to use the AbstractTableModel as the base class for creating subclasses and the DefaultTableModel when subclassing is not required.

The "TableExample" directory in the demo area of the source distribution 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.

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 the values from the model during painting.

By default, 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 model will be queried in its own coordinate 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 coordinate system where the order of the rows is changed, rather than the order of the columns.

J2SE 5 adds methods to JTable to provide convenient access to some common printing needs. Simple new methods allow for quick and easy addition of printing support to your application. In addition, a new #getPrintable method is available for more advanced printing needs.

As for all JComponent classes, you can use InputMap and ActionMap to associate an Action object with a KeyStroke and execute the action under specified conditions.

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 .

@beaninfo
attribute: isContainer false description: A component which displays data in a two dimensional grid.
@version
1.238 06/28/04
@author
Philip Milne
@author
Shannon Hickey (printing support)
Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.
Constructs a JTable that is initialized with dm as the data model, a default column model, and a default selection model.
Parameters
dmthe data model for the table
Constructs a JTable that is initialized with dm as the data model, cm as the column model, and a default selection model.
Parameters
dmthe data model for the table
cmthe column model for the table
Constructs a JTable that 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
dmthe data model for the table
cmthe column model for the table
smthe row selection model for the table
Constructs a JTable with numRows and numColumns of empty cells using DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.
Parameters
numRowsthe number of rows the table holds
numColumnsthe number of columns the table holds
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
rowDatathe data for the new table
columnNamesnames of each column
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]; 

All rows must be of the same length as columnNames.

Parameters
rowDatathe data for the new table
columnNamesnames of each column
During all resize operations, proportionately resize all columns.
During all resize operations, apply adjustments to the last column only.
When a column is adjusted in the UI, adjust the next column the opposite way.
Do not adjust column widths automatically; use a scrollbar.
During UI adjustment, change subsequent columns to preserve the total width; this is the default behavior.
Ease-of-use constant for getAlignmentY. Specifies an alignment to the bottom of the component.
Ease-of-use constant for getAlignmentY and getAlignmentX. Specifies an alignment to the center of the component
Ease-of-use constant for getAlignmentX. Specifies an alignment to the left side of the component.
Ease-of-use constant for getAlignmentX. Specifies an alignment to the right side of the component.
The comment to display when the cursor is over the component, also known as a "value tip", "flyover help", or "flyover label".
Ease-of-use constant for getAlignmentY(). Specifies an alignment to the top of the component.
Constant used by some of the APIs to mean that no condition is defined.
Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component.
Constant used for registerKeyboardAction that means that the command should be invoked when the component has the focus.
Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component.
@deprecated
As of JDK version 1.1, should register this component as ActionListener on component which fires action events.
Appends the specified component to the end of this container. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
Return
the component argument
Adds the specified component to this container at the given position. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
indexthe position at which to insert the component, or -1 to append the component to the end
Return
the component comp
Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the specified constraints object. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
constraintsan object expressing layout contraints for this component
@since
JDK1.1
Adds the specified component to this container with the specified constraints at the specified index. Also notifies the layout manager to add the component to the this container's layout using the specified constraints object. This is a convenience method for #addImpl .

Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

Parameters
compthe component to be added
constraintsan object expressing layout contraints for this
indexthe position in the container's list at which to insert the component; -1 means insert at the end component
Adds the specified popup menu to the component.
Parameters
popupthe popup menu to be added to the component.
@since
JDK1.1
Adds the specified component to this container. This is a convenience method for #addImpl .

This method is obsolete as of 1.1. Please use the method add(Component, Object) instead.

Registers listener so that it will receive AncestorEvents when it or any of its ancestors move or are made visible or invisible. Events are also sent when the component or its ancestors are added or removed from the containment hierarchy.
Parameters
listenerthe AncestorListener to register
See Also
Appends aColumn to the end of the array of columns held by this JTable's column model. If the column name of aColumn is null, sets the column name of aColumn to the name returned by getModel().getColumnName().

To add a column to this JTable to display the modelColumn'th column of data in the model with a given width, cellRenderer, and cellEditor you can use:


      addColumn(new TableColumn(modelColumn, width, cellRenderer, cellEditor));

  
[Any of the TableColumn constructors can be used instead of this one.] The model column number is stored inside the TableColumn and is used during rendering and editing to locate the appropriates data values in the model. The model column number does not change when columns are reordered in the view.
Parameters
aColumnthe TableColumn to be added
See Also
Adds the columns from index0 to index1, inclusive, to the current selection.
Parameters
index0one end of the interval
index1the other end of the interval
Throws
IllegalArgumentExceptionif index0 or index1 lie outside [0, getColumnCount()-1]
Adds the specified component listener to receive component events from this component. If listener l is null, no exception is thrown and no action is performed.
Adds the specified container listener to receive container events from this container. If l is null, no exception is thrown and no action is performed.
Parameters
lthe container listener
Adds the specified focus listener to receive focus events from this component when this component gains input focus. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe focus listener
@since
JDK1.1
Adds the specified hierarchy bounds listener to receive hierarchy bounds events from this component when the hierarchy to which this container belongs changes. If listener l is null, no exception is thrown and no action is performed.
Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes. If listener l is null, no exception is thrown and no action is performed.
Adds the specified input method listener to receive input method events from this component. A component will only receive input method events from input methods if it also overrides getInputMethodRequests to return an InputMethodRequests instance. If listener l is null, no exception is thrown and no action is performed.
Adds the specified key listener to receive key events from this component. If l is null, no exception is thrown and no action is performed.
Parameters
lthe key listener.
@since
JDK1.1
Adds the specified mouse listener to receive mouse events from this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe mouse listener
@since
JDK1.1
Adds the specified mouse motion listener to receive mouse motion events from this component. If listener l is null, no exception is thrown and no action is performed.
Adds the specified mouse wheel listener to receive mouse wheel events from this component. Containers also receive mouse wheel events from sub-components.

For information on how mouse wheel events are dispatched, see the class description for MouseWheelEvent .

If l is null, no exception is thrown and no action is performed.

Calls the configureEnclosingScrollPane method.
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class, including the following:
  • this Container's font ("font")
  • this Container's background color ("background")
  • this Container's foreground color ("foreground")
  • this Container's focusability ("focusable")
  • this Container's focus traversal keys enabled state ("focusTraversalKeysEnabled")
  • this Container's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
  • this Container's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
  • this Container's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
  • this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS ("downCycleFocusTraversalKeys")
  • this Container's focus traversal policy ("focusTraversalPolicy")
  • this Container's focus-cycle-root state ("focusCycleRoot")
Note that if this Container is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined, or one of the following defaults:
  • this Container's font ("font")
  • this Container's background color ("background")
  • this Container's foreground color ("foreground")
  • this Container's focusability ("focusable")
  • this Container's focus traversal keys enabled state ("focusTraversalKeysEnabled")
  • this Container's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
  • this Container's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
  • this Container's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
  • this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS ("downCycleFocusTraversalKeys")
  • this Container's focus traversal policy ("focusTraversalPolicy")
  • this Container's focus-cycle-root state ("focusCycleRoot")
  • this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")
  • this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")
Note that if this Container is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Parameters
propertyNameone of the property names listed above
listenerthe PropertyChangeListener to be added
Adds the rows from index0 to index1, inclusive, to the current selection.
Parameters
index0one end of the interval
index1the other end of the interval
Throws
IllegalArgumentExceptionif index0 or index1 lie outside [0, getRowCount()-1]
Adds a VetoableChangeListener to the listener list. The listener is registered for all properties.
Parameters
listenerthe VetoableChangeListener to be added
Sets the ComponentOrientation property of this container and all components contained within it.
Parameters
othe new component orientation of this container and the components contained within it.
Throws
NullPointerExceptionif orientation is null.
@since
1.4
Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container. If this method returns false, this Container is inheriting the Set from an ancestor, or from the current KeyboardFocusManager.
Parameters
idone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Return
true if the the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Component; false otherwise.
Throws
IllegalArgumentExceptionif id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
@since
1.4
@deprecated
As of JDK version 1.1, replaced by getBounds().
Updates the selection models of the table, depending on the state of the two flags: toggle and extend. Most changes to the selection that are the result of keyboard or mouse events received by the UI are channeled through this method so that the behavior may be overridden by a subclass. Some UIs may need more functionality than this method provides, such as when manipulating the lead for discontiguous selection, and may not call into this method for some selection changes.

This implementation uses the following conventions:

  • toggle: false, extend: false. Clear the previous selection and ensure the new cell is selected.
  • toggle: false, extend: true. Extend the previous selection from the anchor to the specified cell, clearing all other selections.
  • toggle: true, extend: false. If the specified cell is selected, deselect it. If it is not selected, select it.
  • toggle: true, extend: true. Leave the selection state as it is, but move the anchor index to the specified location.
Parameters
rowIndexaffects the selection at row
columnIndexaffects the selection at column
togglesee description above
extendif true, extend the current selection
Returns the status of the construction of a screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface.

Parameters
imagethe Image object whose status is being checked
observerthe ImageObserver object to be notified as the image is being prepared
Return
the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available
@since
JDK1.0
Returns the status of the construction of a screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

The checkImage method of Component calls its peer's checkImage method to calculate the flags. If this component does not yet have a peer, the component's toolkit's checkImage method is called instead.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface.

Parameters
imagethe Image object whose status is being checked
widththe width of the scaled version whose status is to be checked
heightthe height of the scaled version whose status is to be checked
observerthe ImageObserver object to be notified as the image is being prepared
Return
the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available
@since
JDK1.0
Deselects all selected columns and rows.
Tells listeners that a column was added to the model.
Returns the index of the column that point lies in, or -1 if the result is not in the range [0, getColumnCount()-1].
Parameters
pointthe location of interest
Return
the index of the column that point lies in, or -1 if the result is not in the range [0, getColumnCount()-1]
See Also
Tells listeners that a column was moved due to a margin change.
Tells listeners that a column was repositioned.
Tells listeners that a column was removed from the model.
Tells listeners that the selection model of the TableColumnModel changed.
Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors. The return value is stored in visibleRect.
Parameters
visibleRecta Rectangle computed as the intersection of all visible rectangles for this component and all of its ancestors -- this is the return value for this method
Gives the UI delegate an opportunity to define the precise shape of this component for the sake of mouse processing.
Return
true if this component logically contains x,y
Checks whether this component "contains" the specified point, where the point's x and y coordinates are defined to be relative to the coordinate system of this component.
Parameters
pthe point
@since
JDK1.1
Maps the index of the column in the view at viewColumnIndex to the index of the column in the table model. Returns the index of the corresponding column in the model. If viewColumnIndex is less than zero, returns viewColumnIndex.
Parameters
viewColumnIndexthe index of the column in the view
Return
the index of the corresponding column in the model
Maps the index of the column in the table model at modelColumnIndex to the index of the column in the view. Returns the index of the corresponding column in the view; returns -1 if this column is not being displayed. If modelColumnIndex is less than zero, returns modelColumnIndex.
Parameters
modelColumnIndexthe index of the column in the model
Return
the index of the corresponding column in the view
@deprecated
As of JDK version 1.1, replaced by getComponentCount().
Creates default columns for the table from the data model using the getColumnCount method defined in the TableModel interface.

Clears any existing columns before creating the new columns based on information from the model.

Creates an image from the specified image producer.
Parameters
producerthe image producer
Return
the image produced
@since
JDK1.0
Creates an off-screen drawable image to be used for double buffering.
Parameters
widththe specified width
heightthe specified height
Return
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true.
@since
JDK1.0
Equivalent to new JScrollPane(aTable).
@deprecated
As of Swing version 1.0.2, replaced by new JScrollPane(aTable).
Returns the instance of JToolTip that should be used to display the tooltip. Components typically would not override this method, but it can be used to cause different tooltips to be displayed differently.
Return
the JToolTip used to display this toolTip
Creates a volatile off-screen drawable image to be used for double buffering.
Parameters
widththe specified width.
heightthe specified height.
Return
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true.
@since
1.4
Creates a volatile off-screen drawable image, with the given capabilities. The contents of this image may be lost at any time due to operating system issues, so the image must be managed via the VolatileImage interface.
Parameters
widththe specified width.
heightthe specified height.
capsthe image capabilities
Return
a VolatileImage object, which can be used to manage surface contents loss and capabilities.
Throws
AWTExceptionif an image with the specified capabilities cannot be created
@since
1.4
@deprecated
As of JDK version 1.1, replaced by dispatchEvent(AWTEvent e)
@deprecated
As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean).
Dispatches an event to this component or one of its sub components. Calls processEvent before returning for 1.1-style events which have been enabled for the Component.
Parameters
ethe event
Causes this table to lay out its rows and columns. Overridden so that columns can be resized to accomodate a change in the size of a containing parent. Resizes one or more of the columns in the table so that the total width of all of this JTable's columns is equal to the width of the table.

Before the layout begins the method gets the resizingColumn of the tableHeader. When the method is called as a result of the resizing of an enclosing window, the resizingColumn is null. 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 this JTable's automatic resize mode.

If the resizingColumn is not null, it is one of the columns in the table that has changed size rather than the table itself. In this case the auto-resize modes govern the way the extra (or deficit) space is distributed amongst the available columns.

The modes are:

  • AUTO_RESIZE_OFF: Don't automatically adjust the column's widths at all. Use a horizontal scrollbar to accomodate the columns when their sum exceeds the width of the Viewport. If the JTable is not enclosed in a JScrollPane this may leave parts of the table invisible.
  • AUTO_RESIZE_NEXT_COLUMN: Use just the column after the resizing column. This results in the "boundary" or divider between adjacent cells being independently adjustable.
  • AUTO_RESIZE_SUBSEQUENT_COLUMNS: Use all columns after the one being adjusted to absorb the changes. This is the default behavior.
  • AUTO_RESIZE_LAST_COLUMN: Automatically adjust the size of the last column only. If the bounds of the last column prevent the desired size from being allocated, set the width of the last column to the appropriate limit and make no further adjustments.
  • AUTO_RESIZE_ALL_COLUMNS: Spread the delta amongst all the columns in the JTable, including the one that is being adjusted.

Note: When a 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 scroll bar, 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 minimum or maximum, 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.

The mechanism for distributing the delta amongst the available columns is provided in a private method in the JTable class:

   adjustSizes(long targetSize, final Resizable3 r, boolean inverse)
 
an explanation of which is provided in the following section. Resizable3 is a private interface that allows any data structure containing a collection of elements with a size, preferred size, maximum size and minimum size to have its elements manipulated by the algorithm.

Distributing the delta

Overview

Call "DELTA" the difference between the target size and the sum of the preferred sizes of the elements in r. The individual sizes are calculated by taking the original preferred sizes and adding a share of the DELTA - that share being based on how far each preferred size is from its limiting bound (minimum or maximum).

Definition

Call the individual constraints min[i], max[i], and pref[i].

Call their respective sums: MIN, MAX, and PREF.

Each new size will be calculated using:

          size[i] = pref[i] + delta[i]
 
where each individual delta[i] is calculated according to:

If (DELTA < 0) we are in shrink mode where:

                        DELTA
          delta[i] = ------------ * (pref[i] - min[i])
                     (PREF - MIN)
 
If (DELTA > 0) we are in expand mode where:

                        DELTA
          delta[i] = ------------ * (max[i] - pref[i])
                      (MAX - PREF)
 

The overall effect is that the total size moves that same percentage, k, towards the total minimum or maximum and that percentage guarantees accomodation of the required space, DELTA.

Details

Naive evaluation of the formulae presented here would be subject to the aggregated rounding errors caused by doing this operation in finite precision (using ints). To deal with this, the multiplying factor above, is constantly recalculated and this takes account of the rounding errors in the previous iterations. The result is an algorithm that produces a set of integers whose values exactly sum to the supplied targetSize, and does so by spreading the rounding errors evenly over the given elements.

When the MAX and MIN bounds are hit

When targetSize is outside the [MIN, MAX] range, the algorithm sets all sizes to their appropriate limiting value (maximum or minimum).

Programmatically starts editing the cell at row and column, if those indices are in the valid range, and the cell at those indices is editable. Note that this is a convenience method for editCellAt(int, int, null).
Parameters
rowthe row to be edited
columnthe column to be edited
Return
false if for any reason the cell cannot be edited, or if the indices are invalid
Programmatically starts editing the cell at row and column, if those indices are in the valid range, and the cell at those indices 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
rowthe row to be edited
columnthe column to be edited
eevent to pass into shouldSelectCell; note that as of Java 2 platform v1.2, the call to shouldSelectCell is no longer made
Return
false if for any reason the cell cannot be edited, or if the indices are invalid
This tells the listeners the editor has canceled editing
This tells the listeners the editor has ended editing
@deprecated
As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean).
@deprecated
As of JDK version 1.1, replaced by setEnabled(boolean).
Enables or disables input method support for this component. If input method support is enabled and the component also processes key events, incoming events are offered to the current input method and will only be processed by the component or dispatched to its listeners if the input method does not consume them. By default, input method support is enabled.
Parameters
enabletrue to enable, false to disable
@since
1.2
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objthe reference object with which to compare.
Return
true if this object is the same as the obj argument; false otherwise.
Locates the visible child component that contains the specified position. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.

The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container, findComponentAt will search that child to find a nested component.

Parameters
xthe x coordinate
ythe y coordinate
Return
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.
@since
1.2
Locates the visible child component that contains the specified point. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.

The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container, findComponentAt will search that child to find a nested component.

Parameters
pthe point.
Return
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.
@since
1.2
Support for reporting bound property changes for boolean properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.
Parameters
propertyNamethe property whose value has changed
oldValuethe property's previous value
newValuethe property's new value
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a byte)
newValuethe new value of the property (as a byte)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a double)
newValuethe new value of the property (as a double)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a float)
newValuethe new value of the property (as a float)
@since
1.5
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.
Parameters
propertyNamethe property whose value has changed
oldValuethe property's previous value
newValuethe property's new value
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a long)
newValuethe new value of the property (as a long)
@since
1.5
Reports a bound property change.
Parameters
propertyNamethe programmatic name of the property that was changed
oldValuethe old value of the property (as a short)
newValuethe old value of the property (as a short)
@since
1.5
Gets the AccessibleContext associated with this JTable. For tables, the AccessibleContext takes the form of an AccessibleJTable. A new AccessibleJTable instance is created if necessary.
Return
an AccessibleJTable that serves as the AccessibleContext of this JTable
Returns the object that will perform the action registered for a given keystroke.
Return
the ActionListener object invoked when the keystroke occurs
Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding. The returned ActionMap, unless otherwise set, will have the ActionMap from the UI set as the parent.
Return
the ActionMap containing the key/action bindings
@since
1.3
Overrides Container.getAlignmentX to return the vertical alignment.
Return
the value of the alignmentX property
Overrides Container.getAlignmentY to return the horizontal alignment.
Return
the value of the alignmentY property
Returns an array of all the ancestor listeners registered on this component.
Return
all of the component's AncestorListeners or an empty array if no ancestor listeners are currently registered
@since
1.4
Determines whether the table will create default columns from the model. If true, setModel will clear any existing columns and create new columns from the new model. Also, if the event in the tableChanged notification specifies that the entire table changed, then the columns will be rebuilt. The default is true.
Return
the autoCreateColumnsFromModel of the table
Returns the auto resize mode of the table. The default mode is AUTO_RESIZE_SUBSEQUENT_COLUMNS.
Return
the autoResizeMode of the table
Gets the autoscrolls property.
Return
the value of the autoscrolls property
Gets the background color of this component.
Return
this component's background color; if this component does not have a background color, the background color of its parent is returned
@since
JDK1.0
Returns the border of this component or null if no border is currently set.
Return
the border object for this component
See Also
Gets the bounds of this component in the form of a Rectangle object. The bounds specify this component's width, height, and location relative to its parent.
Return
a rectangle indicating this component's bounds
Stores the bounds of this component into "return value" rv and returns rv. If rv is null a new Rectangle is allocated. This version of getBounds is useful if the caller wants to avoid allocating a new Rectangle object on the heap.
Parameters
rvthe return value, modified to the component's bounds
Return
rv; if rv is null return a newly created Rectangle with this component's bounds
Returns the cell editor.
Return
the TableCellEditor that does the editing
See Also
Returns an appropriate editor for the cell specified by row and column. If the TableColumn for this column has a non-null editor, returns that. If not, finds the class of the data in this column (using getColumnClass) and returns the default editor for this type of data.

Note: Throughout the table package, the internal implementations always use this method to provide editors so that this default behavior can be safely overridden by a subclass.

Parameters
rowthe row of the cell to edit, where 0 is the first row
columnthe column of the cell to edit, where 0 is the first column
Return
the editor for this cell; if null return the default editor for this type of cell
Returns a rectangle for the cell that lies at the intersection of row and column. If includeSpacing is true then the value returned has the full height and width of the row and column specified. If it is false, the returned rectangle is inset by the intercell spacing to return the true bounds of the rendering or editing component as it will be set during rendering.

If the column index is valid but the row index is less than zero the method returns a rectangle with the y and height values set appropriately and the x and width values both set to zero. In general, when either the row or column indices indicate a cell outside the appropriate range, the method returns a rectangle depicting the closest edge of the closest cell that is within the table's range. When both row and column indices are out of range the returned rectangle covers the closest point of the closest cell.

In all cases, calculations that use this method to calculate results along one axis will not fail because of anomalies in calculations along the other axis. When the cell is not valid the includeSpacing parameter is ignored.

Parameters
rowthe row index where the desired cell is located
columnthe column index where the desired cell is located in the display; this is not necessarily the same as the column index in the data model for the table; the {@link #convertColumnIndexToView(int)} method may be used to convert a data model column index to a display column index
includeSpacingif false, return the true cell bounds - computed by subtracting the intercell spacing from the height and widths of the column and row models
Return
the rectangle containing the cell at location row,column
Returns an appropriate renderer for the cell specified by this row and column. If the TableColumn for this column has a non-null renderer, returns that. If not, finds the class of the data in this column (using getColumnClass) and returns the default renderer for this type of data.

Note: Throughout the table package, the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass.

Parameters
rowthe row of the cell to render, where 0 is the first row
columnthe column of the cell to render, where 0 is the first column
Return
the assigned renderer; if null returns the default renderer for this type of object
Returns true if both row and column selection models are enabled. Equivalent to getRowSelectionAllowed() && getColumnSelectionAllowed().
Return
true if both row and column selection models are enabled
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns the value of the property with the specified key. Only properties added with putClientProperty will return a non-null value.
Parameters
keythe being queried
Return
the value of this property or null
Gets the instance of ColorModel used to display the component on the output device.
Return
the color model used by this component
@since
JDK1.0
Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals.
Parameters
identifierthe identifier object
Return
the TableColumn object that matches the identifier
Throws
IllegalArgumentExceptionif identifier is null or no TableColumn has this identifier
Returns the type of the column appearing in the view at column position column.
Parameters
columnthe column in the view being queried
Return
the type of the column at position column in the view where the first column is column 0
Returns the number of columns in the column model. Note that this may be different from the number of columns in the table model.
Return
the number of columns in the table
Returns the TableColumnModel that contains all column information of this table.
Return
the object that provides the column state of the table
Returns the name of the column appearing in the view at column position column.
Parameters
columnthe column in the view being queried
Return
the name of the column at position column in the view where the first column is column 0
Returns true if columns can be selected.
Return
true if columns can be selected, otherwise false
Gets the nth component in this container.
Parameters
nthe index of the component to get.
Return
the nth component in this container.
Throws
ArrayIndexOutOfBoundsExceptionif the nth value does not exist.
Locates the component that contains the x,y position. The top-most child component is returned in the case where there is overlap in the components. This is determined by finding the component closest to the index 0 that claims to contain the given point via Component.contains(), except that Components which have native peers take precedence over those which do not (i.e., lightweight Components).
Parameters
xthe x coordinate
ythe y coordinate
Return
null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned; otherwise the top-most child is returned.
@since
JDK1.1
Gets the component that contains the specified point.
Parameters
pthe point.
Return
returns the component that contains the point, or null if the component does not contain the point.
@since
JDK1.1
Gets the number of components in this panel.
Return
the number of components in this panel.
@since
JDK1.1
See Also
Returns an array of all the component listeners registered on this component.
Return
all of this comonent's ComponentListeners or an empty array if no component listeners are currently registered
@since
1.4
Retrieves the language-sensitive orientation that is to be used to order the elements or text within this component. LayoutManager and Component subclasses that wish to respect orientation should call this method to get the component's orientation before performing layout or drawing.
@author
Laura Werner, IBM
Returns JPopupMenu that assigned for this component. If this component does not have a JPopupMenu assigned to it and getInheritsPopupMenu is true, this will return getParent().getComponentPopupMenu() (assuming the parent is valid.)
Return
JPopupMenu assigned for this component or null if no popup assigned
@since
1.5
Gets all the components in this container.
Return
an array of all the components in this container.
Returns the z-order index of the component inside the container. The higher a component is in the z-order hierarchy, the lower its index. The component with the lowest z-order index is painted last, above all other child components.
Parameters
compthe component being queried
Return
the z-order index of the component; otherwise returns -1 if the component is null
@since
1.5
Returns the condition that determines whether a registered action occurs in response to the specified keystroke.

For Java 2 platform v1.3, a KeyStroke can be associated with more than one condition. For example, 'a' could be bound for the two conditions WHEN_FOCUSED and WHEN_IN_FOCUSED_WINDOW condition.

Return
the action-keystroke condition
Returns an array of all the container listeners registered on this container.
Return
all of this container's ContainerListeners or an empty array if no container listeners are currently registered
@since
1.4
Gets the cursor set in the component. If the component does not have a cursor set, the cursor of its parent is returned. If no cursor is set in the entire hierarchy, Cursor.DEFAULT_CURSOR is returned.
@since
JDK1.1
See Also
Returns the state of graphics debugging.
Return
a bitwise OR'd flag of zero or more of the following options:
  • DebugGraphics.LOG_OPTION - causes a text message to be printed.
  • DebugGraphics.FLASH_OPTION - causes the drawing to flash several times.
  • DebugGraphics.BUFFERED_OPTION - creates an ExternalWindow that displays the operations performed on the View's offscreen buffer.
  • DebugGraphics.NONE_OPTION disables debugging.
  • A value of 0 causes no changes to the debugging options.
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 of which can be modified or replaced.
Parameters
columnClassreturn the default cell editor for this columnClass
Return
the default cell editor to be used for this columnClass
Returns the default locale used to initialize each JComponent's locale property upon creation. The default locale has "AppContext" scope so that applets (and potentially multiple lightweight applications running in a single VM) can have their own setting. An applet can safely alter its default locale because it will have no affect on other applets (or the browser).
Return
the default Locale.
@since
1.4
Returns the cell 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 of which can be modified or replaced.
Parameters
columnClassreturn the default cell renderer for this columnClass
Return
the renderer for this columnClass
Gets the value of the dragEnabled property.
Return
the value of the dragEnabled property
@since
1.4
Gets the DropTarget associated with this Component.
Returns the index of the column that contains the cell currently being edited. If nothing is being edited, returns -1.
Return
the index of the column that contains the cell currently being edited; returns -1 if nothing being edited
See Also
Returns the index of the row that contains the cell currently being edited. If nothing is being edited, returns -1.
Return
the index of the row that contains the cell currently being edited; returns -1 if nothing being edited
Returns the component that is handling the editing session. If nothing is being edited, returns null.
Return
Component handling editing session
Returns the Container which is the focus cycle root of this Component's focus traversal cycle. Each focus traversal cycle has only a single focus cycle root and each Component which is not a Container belongs to only a single focus traversal cycle. Containers which are focus cycle roots belong to two cycles: one rooted at the Container itself, and one rooted at the Container's nearest focus-cycle-root ancestor. For such Containers, this method will return the Container's nearest focus-cycle- root ancestor.
Return
this Component's nearest focus-cycle-root ancestor
@since
1.4
Returns an array of all the focus listeners registered on this component.
Return
all of this component's FocusListeners or an empty array if no component listeners are currently registered
@since
1.4
Returns the Set of focus traversal keys for a given traversal operation for this Container. (See setFocusTraversalKeys for a full description of each key.)

If a Set of traversal keys has not been explicitly defined for this Container, then this Container's parent's Set is returned. If no Set has been explicitly defined for any of this Container's ancestors, then the current KeyboardFocusManager's default Set is returned.

Parameters
idone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
Return
the Set of AWTKeyStrokes for the specified operation. The Set will be unmodifiable, and may be empty. null will never be returned.
Throws
IllegalArgumentExceptionif id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
@since
1.4
Returns whether focus traversal keys are enabled for this Component. Components for which focus traversal keys are disabled receive key events for focus traversal keys. Components for which focus traversal keys are enabled do not see these events; instead, the events are automatically converted to traversal operations.
Return
whether focus traversal keys are enabled for this Component
@since
1.4
Returns the focus traversal policy that will manage keyboard traversal of this Container's children, or null if this Container is not a focus cycle root. If no traversal policy has been explicitly set for this Container, then this Container's focus-cycle-root ancestor's policy is returned.
Return
this Container's focus traversal policy, or null if this Container is not a focus cycle root.
@since
1.4
Gets the font of this component.
Return
this component's font; if a font has not been set for this component, the font of its parent is returned
@since
JDK1.0
See Also
Gets the FontMetrics for the specified Font.
Parameters
fontthe font for which font metrics is to be obtained
Return
the font metrics for font
Throws
NullPointerExceptionif font is null
@since
1.5
Gets the foreground color of this component.
Return
this component's foreground color; if this component does not have a foreground color, the foreground color of its parent is returned
@since
JDK1.0
@beaninfo
bound: true
Returns this component's graphics context, which lets you draw on a component. Use this method get a Graphics object and then invoke operations on that object to draw on the component.
Return
this components graphics context
Gets the GraphicsConfiguration associated with this Component. If the Component has not been assigned a specific GraphicsConfiguration, the GraphicsConfiguration of the Component object's top-level container is returned. If the Component has been created, but not yet added to a Container, this method returns null.
Return
the GraphicsConfiguration used by this Component or null
@since
1.3
Returns the color used to draw grid lines. The default color is look and feel dependent.
Return
the color used to draw grid lines
See Also
Returns the current height of this component. This method is preferable to writing component.getBounds().height, or component.getSize().height because it doesn't cause any heap allocations.
Return
the current height of this component
Returns an array of all the hierarchy bounds listeners registered on this component.
Return
all of this component's HierarchyBoundsListeners or an empty array if no hierarchy bounds listeners are currently registered
@since
1.4
Returns an array of all the hierarchy listeners registered on this component.
Return
all of this component's HierarchyListeners or an empty array if no hierarchy listeners are currently registered
@since
1.4
Return
whether or not paint messages received from the operating system should be ignored.
@since
1.4
Returns true if the JPopupMenu should be inherited from the parent.
@since
1.5
Gets the input context used by this component for handling the communication with input methods when text is entered in this component. By default, the input context used for the parent component is returned. Components may override this to return a private input context.
Return
the input context used by this component; null if no context can be determined
@since
1.2
Returns the InputMap that is used when the component has focus. This is convenience method for getInputMap(WHEN_FOCUSED).
Return
the InputMap used when the component has focus
@since
JDK1.3
Returns the InputMap that is used during condition.
Parameters
conditionone of WHEN_IN_FOCUSED_WINDOW, WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
Return
the InputMap for the specified condition
@since
1.3
Returns an array of all the input method listeners registered on this component.
Return
all of this component's InputMethodListeners or an empty array if no input method listeners are currently registered
@since
1.4
Gets the input method request handler which supports requests from input methods for this component. A component that supports on-the-spot text input must override this method to return an InputMethodRequests instance. At the same time, it also has to handle input method events.
Return
the input method request handler for this component, null by default
@since
1.2
Returns the input verifier for this component.
Return
the inputVerifier property
@since
1.3
See Also
If a border has been set on this component, returns the border's insets; otherwise calls super.getInsets.
Return
the value of the insets property
See Also
Returns an Insets object containing this component's inset values. The passed-in Insets object will be reused if possible. Calling methods cannot assume that the same object will be returned, however. All existing values within this object are overwritten. If insets is null, this will allocate a new one.
Parameters
insetsthe Insets object, which can be reused
Return
the Insets object
@beaninfo
expert: true
See Also
Returns the horizontal and vertical space between cells. The default spacing is (1, 1), which provides room to draw the grid.
Return
the horizontal and vertical spacing between cells
Returns an array of all the key listeners registered on this component.
Return
all of this component's KeyListeners or an empty array if no key listeners are currently registered
@since
1.4
Gets the layout manager for this container.
Returns an array of all the objects currently registered as FooListeners upon this JComponent. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a JComponent c for its mouse listeners with the following code:

MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));
If no such listeners exist, this method returns an empty array.
Parameters
listenerTypethe type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Return
an array of all objects registered as FooListeners on this component, or an empty array if no such listeners have been added
Throws
ClassCastExceptionif listenerType doesn't specify a class or interface that implements java.util.EventListener
@since
1.3
Gets the locale of this component.
Return
this component's locale; if this component does not have a locale, the locale of its parent is returned
Throws
IllegalComponentStateExceptionif the Component does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent
@since
JDK1.1
See Also
Gets the location of this component in the form of a point specifying the component's top-left corner. The location will be relative to the parent's coordinate space.

Due to the asynchronous nature of native event handling, this method can return outdated values (for instance, after several calls of setLocation() in rapid succession). For this reason, the recommended method of obtaining a component's position is within java.awt.event.ComponentListener.componentMoved(), which is called after the operating system has finished moving the component.

Return
an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the component's parent
@since
JDK1.1
Stores the x,y origin of this component into "return value" rv and returns rv. If rv is null a new Point is allocated. This version of getLocation is useful if the caller wants to avoid allocating a new Point object on the heap.
Parameters
rvthe return value, modified to the component's location
Return
rv
Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.
Return
an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen
Throws
IllegalComponentStateExceptionif the component is not showing on the screen
If the maximum size has been set to a non-null value just returns it. If the UI delegate's getMaximumSize method returns a non-null value then return that; otherwise defer to the component's layout manager.
Return
the value of the maximumSize property
If the minimum size has been set to a non-null value just returns it. If the UI delegate's getMinimumSize method returns a non-null value then return that; otherwise defer to the component's layout manager.
Return
the value of the minimumSize property
Returns the TableModel that provides the data displayed by this JTable.
Return
the TableModel that provides the data displayed by this JTable
See Also
Returns an array of all the mouse listeners registered on this component.
Return
all of this component's MouseListeners or an empty array if no mouse listeners are currently registered
@since
1.4
Returns an array of all the mouse motion listeners registered on this component.
Return
all of this component's MouseMotionListeners or an empty array if no mouse motion listeners are currently registered
@since
1.4
Returns the position of the mouse pointer in this Component's coordinate space if the Component is directly under the mouse pointer, otherwise returns null. If the Component is not showing on the screen, this method returns null even if the mouse pointer is above the area where the Component would be displayed. If the Component is partially or fully obscured by other Components or native windows, this method returns a non-null value only if the mouse pointer is located above the unobscured part of the Component.

For Containers it returns a non-null value if the mouse is above the Container itself or above any of its descendants. Use if you need to exclude children.

Sometimes the exact mouse coordinates are not important, and the only thing that matters is whether a specific Component is under the mouse pointer. If the return value of this method is null, mouse pointer is not directly above the Component.

Return
mouse coordinates relative to this Component, or null
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.5
Returns the position of the mouse pointer in this Container's coordinate space if the Container is under the mouse pointer, otherwise returns null. This method is similar to with the exception that it can take the Container's children into account. If allowChildren is false, this method will return a non-null value only if the mouse pointer is above the Container directly, not above the part obscured by children. If allowChildren is true, this method returns a non-null value if the mouse pointer is above Container or any of its descendants.
Parameters
allowChildrentrue if children should be taken into account
Return
mouse coordinates relative to this Component, or null
Throws
HeadlessExceptionif GraphicsEnvironment.isHeadless() returns true
@since
1.5
Returns an array of all the mouse wheel listeners registered on this component.
Return
all of this component's MouseWheelListeners or an empty array if no mouse wheel listeners are currently registered
@since
1.4
Gets the name of the component.
Return
this component's name
@since
JDK1.1
See Also
In release 1.4, the focus subsystem was rearchitected. For more information, see How to Use the Focus Subsystem, a section in The Java Tutorial.

Returns the Component set by a prior call to setNextFocusableComponent(Component) on this JComponent.

Return
the Component that will follow this JComponent in the focus traversal cycle, or null if none has been explicitly specified
@deprecated
As of 1.4, replaced by FocusTraversalPolicy.
Gets the parent of this component.
Return
the parent container of this component
@since
JDK1.0
@deprecated
As of JDK version 1.1, programs should not directly manipulate peers; replaced by boolean isDisplayable().
Returns the preferred location to display the popup menu in this component's coordinate system. It is up to the look and feel to honor this propery, some may choose to ignore it. If null is truend the look and feel will choose a suitable location.
Parameters
eventthe MouseEvent that triggered the popup to be shown, or null if popup was is not being shown as the result of a mouse event
Return
Locatino to display the JPopupMenu.
@since
1.5
Returns the preferred size of the viewport for a view component. For example, the preferred size of a JList component is the size required to accommodate all of the cells in its list. However, the value of preferredScrollableViewportSize is the size required for JList.getVisibleRowCount rows. A component without any properties that would affect the viewport size should just return getPreferredSize here.
Return
the preferredSize of a JViewport whose view is this Scrollable
If the preferredSize has been set to a non-null value just returns it. If the UI delegate's getPreferredSize method returns a non null value then return that; otherwise defer to the component's layout manager.
Return
the value of the preferredSize property
Return a Printable for use in printing this JTable.

The Printable can be requested in one of two printing modes. In both modes, it spreads table rows naturally in sequence across multiple pages, fitting as many rows as possible per page. PrintMode.NORMAL specifies that the table be printed at its current size. In this mode, there may be a need to spread columns across pages in a similar manner to that of the rows. When the need arises, columns are distributed in an order consistent with the table's ComponentOrientation. PrintMode.FIT_WIDTH specifies that the output be scaled smaller, if necessary, to fit the table's entire width (and thereby all columns) on each page. Width and height are scaled equally, maintaining the aspect ratio of the output.

The Printable heads the portion of table on each page with the appropriate section from the table's JTableHeader, if it has one.

Header and footer text can be added to the output by providing MessageFormat arguments. The printing code requests Strings from the formats, providing a single item which may be included in the formatted string: an Integer representing the current page number.

You are encouraged to read the documentation for MessageFormat as some characters, such as single-quote, are special and need to be escaped.

Here's an example of creating a MessageFormat that can be used to print "Duke's Table: Page - " and the current page number:

     // notice the escaping of the single quote
     // notice how the page number is included with "{0}"
     MessageFormat format = new MessageFormat("Duke''s Table: Page - {0}");
 

The Printable constrains what it draws to the printable area of each page that it prints. Under certain circumstances, it may find it impossible to fit all of a page's content into that area. In these cases the output may be clipped, but the implementation makes an effort to do something reasonable. Here are a few situations where this is known to occur, and how they may be handled by this particular implementation:

  • In any mode, when the header or footer text is too wide to fit completely in the printable area -- print as much of the text as possible starting from the beginning, as determined by the table's ComponentOrientation.
  • In any mode, when a row is too tall to fit in the printable area -- print the upper-most portion of the row and paint no lower border on the table.
  • In PrintMode.NORMAL when a column is too wide to fit in the printable area -- print the center portion of the column and leave the left and right borders off the table.

It is entirely valid for this Printable to be wrapped inside another in order to create complex reports and documents. You may even request that different pages be rendered into different sized printable areas. The implementation must be prepared to handle this (possibly by doing its layout calculations on the fly). However, providing different heights to each page will likely not work well with PrintMode.NORMAL when it has to spread columns across pages.

It is important to note that this Printable prints the table at its current visual state, using the table's existing renderers. Before calling this method, you may wish to first modify the state of the table (such as to change the renderers, cancel editing, or hide the selection).

You must not, however, modify the table in any way after this Printable is fetched (invalid modifications include changes in: size, renderers, or underlying data). The behavior of the returned Printable is undefined once the table has been changed.

Here's a simple example that calls this method to fetch a Printable, shows a cross-platform print dialog, and then prints the Printable unless the user cancels the dialog:

     // prepare the table for printing here first (for example, hide selection)

     // wrap in a try/finally so table can be restored even if something fails
     try {
         // fetch the printable
         Printable printable = table.getPrintable(JTable.PrintMode.FIT_WIDTH,
                                                  new MessageFormat("My Table"),
                                                  new MessageFormat("Page - {0}"));

         // fetch a PrinterJob
         PrinterJob job = PrinterJob.getPrinterJob();

         // set the Printable on the PrinterJob
         job.setPrintable(printable);

         // create an attribute set to store attributes from the print dialog
         PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();

         // display a print dialog and record whether or not the user cancels it
         boolean printAccepted = job.printDialog(attr);

         // if the user didn't cancel the dialog
         if (printAccepted) {
             // do the printing (may need to handle PrinterException)
             job.print(attr);
         }
     } finally {
         // restore the original table state here (for example, restore selection)
     }
 
Parameters
printModethe printing mode that the printable should use
headerFormata MessageFormat specifying the text to be used in printing a header, or null for none
footerFormata MessageFormat specifying the text to be used in printing a footer, or null for none
Return
a Printable for printing this JTable
@since
1.5
Returns an array of all the property change listeners registered on this component.
Return
all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
@since
1.4
Returns an array of all the listeners which have been associated with the named property.
Return
all of the PropertyChangeListeners associated with the named property; if no such listeners have been added or if propertyName is null, an empty array is returned
@since
1.4
Returns the KeyStrokes that will initiate registered actions.
Return
an array of KeyStroke objects
Returns the JRootPane ancestor for this component.
Return
the JRootPane that contains this component, or null if no JRootPane is found
Returns the number of rows in this table's model.
Return
the number of rows in this table's model
Returns the height of a table row, in pixels. The default row height is 16.0.
Return
the height in pixels of a table row
See Also
Returns the height, in pixels, of the cells in row.
Parameters
rowthe row whose height is to be returned
Return
the height, in pixels, of the cells in the row
Gets the amount of empty space, in pixels, between cells. Equivalent to: getIntercellSpacing().height.
Return
the number of pixels between cells in a row
See Also
Returns true if rows can be selected.
Return
true if rows can be selected, otherwise false
Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation.

Scrolling containers, like JScrollPane, will use this method each time the user requests a block scroll.

Parameters
visibleRectThe view area visible within the viewport
orientationEither SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
directionLess than zero to scroll up/left, greater than zero for down/right.
Return
The "block" increment for scrolling in the specified direction. This value should always be positive.
Return true if a viewport should always force the height of this Scrollable to match the height of the viewport. For example a columnar text view that flowed text in left to right columns could effectively disable vertical scrolling by returning true here.

Scrolling containers, like JViewport, will use this method each time they are validated.

Return
True if a viewport should force the Scrollables height to match its own.
Return true if a viewport should always force the width of this Scrollable to match the width of the viewport. For example a normal text view that supported line wrapping would return true here, since it would be undesirable for wrapped lines to disappear beyond the right edge of the viewport. Note that returning true for a Scrollable whose ancestor is a JScrollPane effectively disables horizontal scrolling.

Scrolling containers, like JViewport, will use this method each time they are validated.

Return
True if a viewport should force the Scrollables width to match its own.
Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. Ideally, components should handle a partially exposed row or column by returning the distance required to completely expose the item.

Scrolling containers, like JScrollPane, will use this method each time the user requests a unit scroll.

Parameters
visibleRectThe view area visible within the viewport
orientationEither SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
directionLess than zero to scroll up/left, greater than zero for down/right.
Return
The "unit" increment for scrolling in the specified direction. This value should always be positive.
Returns the index of the first selected column, -1 if no column is selected.
Return
the index of the first selected column
Returns the number of selected columns.
Return
the number of selected columns, 0 if no columns are selected
Returns the indices of all selected columns.
Return
an array of integers containing the indices of all selected columns, or an empty array if no column is selected
Returns the index of the first selected row, -1 if no row is selected.
Return
the index of the first selected row
Returns the number of selected rows.
Return
the number of selected rows, 0 if no rows are selected
Returns the indices of all selected rows.
Return
an array of integers containing the indices of all selected rows, or an empty array if no row is selected
Returns the background color for selected cells.
Return
the Color used for the background of selected list items
Returns the foreground color for selected cells.
Return
the Color object for the foreground property
Returns the ListSelectionModel that is used to maintain row selection state.
Return
the object that provides row selection state, null if row selection is not allowed
Returns true if the table draws horizontal lines between cells, false if it doesn't. The default is true.
Return
true if the table draws horizontal lines between cells, false if it doesn't
Returns true if the table draws vertical lines between cells, false if it doesn't. The default is true.
Return
true if the table draws vertical lines between cells, false if it doesn't
Returns the size of this component in the form of a Dimension object. The height field of the Dimension object contains this component's height, and the width field of the Dimension object contains this component's width.
Return
a Dimension object that indicates the size of this component
@since
JDK1.1
See Also
Stores the width/height of this component into "return value" rv and returns rv. If rv is null a new Dimension object is allocated. This version of getSize is useful if the caller wants to avoid allocating a new Dimension object on the heap.
Parameters
rvthe return value, modified to the component's size
Return
rv
Returns true if the editor should get the focus when keystrokes cause the editor to be activated
Return
true if the editor should get the focus when keystrokes cause the editor to be activated
Returns the tableHeader used by this JTable.
Return
the tableHeader used by this table
Gets the toolkit of this component. Note that the frame that contains a component controls which toolkit is used by that component. Therefore if the component is moved from one frame to another, the toolkit it uses may change.
Return
the toolkit of this component
@since
JDK1.0
Returns the tooltip location in this component's coordinate system. If null is returned, Swing will choose a location. The default implementation returns null.
Parameters
eventthe MouseEvent that caused the ToolTipManager to show the tooltip
Return
always returns null
Returns the tooltip string that has been set with setToolTipText.
Return
the text of the tool tip
Overrides JComponent's getToolTipText method in order to allow the renderer's tips to be used if it 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.

Returns the top-level ancestor of this component (either the containing Window or Applet), or null if this component has not been added to any container.
Return
the top-level Container that this component is in, or null if not in any container
Gets the transferHandler property.
Return
the value of the transferHandler property
@since
1.4
Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations.
Return
this component's locking object
Returns the L&F object that renders this component.
Return
the TableUI object that renders this component
Returns the suffix used to construct the name of the L&F class used to render this component.
Return
the string "TableUI"
Returns the cell value at row and 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, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

Parameters
rowthe row whose value is to be queried
columnthe column whose value is to be queried
Return
the Object at the specified cell
Returns the value that indicates whether the input verifier for the current focus owner will be called before this component requests focus.
Return
value of the verifyInputWhenFocusTarget property
@since
1.3
Returns an array of all the vetoable change listeners registered on this component.
Return
all of the component's VetoableChangeListeners or an empty array if no vetoable change listeners are currently registered
@since
1.4
Returns the Component's "visible rectangle" - the intersection of this component's visible rectangle, new Rectangle(0, 0, getWidth(), getHeight()), and all of its ancestors' visible rectangles.
Return
the visible rectangle
Returns the current width of this component. This method is preferable to writing component.getBounds().width, or component.getSize().width because it doesn't cause any heap allocations.
Return
the current width of this component
Returns the current x coordinate of the component's origin. This method is preferable to writing component.getBounds().x, or component.getLocation().x because it doesn't cause any heap allocations.
Return
the current x coordinate of the component's origin
Returns the current y coordinate of the component's origin. This method is preferable to writing component.getBounds().y, or component.getLocation().y because it doesn't cause any heap allocations.
Return
the current y coordinate of the component's origin
@deprecated
As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).
Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window. This component must be displayable, visible, and focusable for the request to be granted.

This method is intended for use by focus implementations. Client code should not use this method; instead, it should use requestFocusInWindow().

@deprecated
As of JDK version 1.1 replaced by processEvent(AWTEvent).
Returns true if this Component is the focus owner. This method is obsolete, and has been replaced by isFocusOwner().
Return
true if this Component is the focus owner; false otherwise
@since
1.2
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Return
a hash code value for this object.
@deprecated
As of JDK version 1.1, replaced by setVisible(boolean).
Repaints the component when the image has changed. This imageUpdate method of an ImageObserver is called when more information about an image which had been previously requested using an asynchronous routine such as the drawImage method of Graphics becomes available. See the definition of imageUpdate for more information on this method and its arguments.

The imageUpdate method of Component incrementally draws an image on the component as more of the bits of the image are available.

If the system property awt.image.incrementaldraw is missing or has the value true, the image is incrementally drawn. If the system property has any other value, then the image is not drawn until it has been completely loaded.

Also, if incremental drawing is in effect, the value of the system property awt.image.redrawrate is interpreted as an integer to give the maximum redraw rate, in milliseconds. If the system property is missing or cannot be interpreted as an integer, the redraw rate is once every 100ms.

The interpretation of the x, y, width, and height arguments depends on the value of the infoflags argument.

Parameters
imgthe image being observed
infoflagssee imageUpdate for more information
xthe x coordinate
ythe y coordinate
wthe width
hthe height
Return
false if the infoflags indicate that the image is completely loaded; true otherwise.
@since
JDK1.0
@deprecated
As of JDK version 1.1, replaced by getInsets().
@deprecated
As of JDK version 1.1, replaced by contains(int, int).
Invalidates the container. The container and all parents above it are marked as needing to be laid out. This method can be called often, so it needs to execute quickly.
Checks if the component is contained in the component hierarchy of this container.
Parameters
cthe component
Return
true if it is an ancestor; false otherwise.
@since
JDK1.1
Returns whether the background color has been explicitly set for this Component. If this method returns false, this Component is inheriting its background color from an ancestor.
Return
true if the background color has been explicitly set for this Component; false otherwise.
@since
1.4
Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.

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, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.

Parameters
rowthe row whose value is to be queried
columnthe column whose value is to be queried
Return
true if the cell is editable
See Also
Returns true if the specified indices are in the valid range of rows and columns and the cell at the specified position is selected.
Parameters
rowthe row being queried
columnthe column being queried
Return
true if row and column are valid indices and the cell at index (row, column) is selected, where the first row and first column are at index 0
Returns true if the specified index is in the valid range of columns, and the column at that index is selected.
Parameters
columnthe column in the column model
Return
true if column is a valid index and the column at that index is selected (where 0 is the first column)
Returns whether the cursor has been explicitly set for this Component. If this method returns false, this Component is inheriting its cursor from an ancestor.
Return
true if the cursor has been explicitly set for this Component; false otherwise.
@since
1.4
Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.

A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor window is either packed or made visible.

A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed.

Return
true if the component is displayable, false otherwise
@since
1.2
Returns whether this component should use a buffer to paint.
Return
true if this component is double buffered, otherwise false
Returns true if a cell is being edited.
Return
true if the table is editing a cell
Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default. A component may be enabled or disabled by calling its setEnabled method.
Return
true if the component is enabled, false otherwise
@since
JDK1.0
See Also
Returns whether this Component can be focused.
Return
true if this Component is focusable; false otherwise.
@since
1.4
See Also
Returns whether this Container is the root of a focus traversal cycle. Once focus enters a traversal cycle, typically it cannot leave it via focus traversal unless one of the up- or down-cycle keys is pressed. Normal traversal is limited to this Container, and all of this Container's descendants that are not descendants of inferior focus cycle roots. Note that a FocusTraversalPolicy may bend these restrictions, however. For example, ContainerOrderFocusTraversalPolicy supports implicit down-cycle traversal.
Return
whether this Container is the root of a focus traversal cycle
@since
1.4
Returns whether the specified Container is the focus cycle root of this Container's focus traversal cycle. Each focus traversal cycle has only a single focus cycle root and each Container which is not a focus cycle root belongs to only a single focus traversal cycle. Containers which are focus cycle roots belong to two cycles: one rooted at the Container itself, and one rooted at the Container's nearest focus-cycle-root ancestor. This method will return true for both such Containers in this case.
Parameters
containerthe Container to be tested
Return
true if the specified Container is a focus-cycle- root of this Container; false otherwise
@since
1.4
Returns true if this Component is the focus owner.
Return
true if this Component is the focus owner; false otherwise
@since
1.4
Returns whether this Component can become the focus owner.
Return
true if this Component is focusable; false otherwise
@since
JDK1.1
@deprecated
As of 1.4, replaced by isFocusable().
See Also
Returns whether this container provides focus traversal policy. If this property is set to true then when keyboard focus manager searches container hierarchy for focus traversal policy and encounters this container before any other container with this property as true or focus cycle roots then its focus traversal policy will be used instead of focus cycle root's policy.
Return
true if this container provides focus traversal policy, false otherwise
@since
1.5
@beaninfo
bound: true
Returns whether the focus traversal policy has been explicitly set for this Container. If this method returns false, this Container will inherit its focus traversal policy from an ancestor.
Return
true if the focus traversal policy has been explicitly set for this Container; false otherwise.
@since
1.4
Returns whether the font has been explicitly set for this Component. If this method returns false, this Component is inheriting its font from an ancestor.
Return
true if the font has been explicitly set for this Component; false otherwise.
@since
1.4
Returns whether the foreground color has been explicitly set for this Component. If this method returns false, this Component is inheriting its foreground color from an ancestor.
Return
true if the foreground color has been explicitly set for this Component; false otherwise.
@since
1.4
A lightweight component doesn't have a native toolkit peer. Subclasses of Component and Container, other than the ones defined in this package like Button or Scrollbar, are lightweight. All of the Swing components are lightweights.

This method will always return false if this component is not displayable because it is impossible to determine the weight of an undisplayable component.

Return
true if this component has a lightweight peer; false if it has a native peer or no peer
@since
1.2
Returns true if this component is lightweight, that is, if it doesn't have a native window system peer.
Return
true if this component is lightweight
In release 1.4, the focus subsystem was rearchitected. For more information, see How to Use the Focus Subsystem, a section in The Java Tutorial.

Changes this JComponent's focus traversal keys to CTRL+TAB and CTRL+SHIFT+TAB. Also prevents SortingFocusTraversalPolicy from considering descendants of this JComponent when computing a focus traversal cycle.

@deprecated
As of 1.4, replaced by Component.setFocusTraversalKeys(int, Set) and Container.setFocusCycleRoot(boolean).
Returns true if the maximum size has been set to a non-null value otherwise returns false.
Return
true if maximumSize is non-null, false otherwise
@since
1.5
Returns whether or not setMinimumSize has been invoked with a non-null value.
Return
true if setMinimumSize has been invoked with a non-null value.
@since
1.5
Returns true if this component is completely opaque.

An opaque component paints every pixel within its rectangular bounds. A non-opaque component paints only a subset of its pixels or none at all, allowing the pixels underneath it to "show through". Therefore, a component that does not fully paint its pixels provides a degree of transparency.

Subclasses that guarantee to always completely paint their contents should override this method and return true.

Return
true if this component is completely opaque
See Also
Returns true if this component tiles its children -- that is, if it can guarantee that the children will not overlap. The repainting system is substantially more efficient in this common case. JComponent subclasses that can't make this guarantee, such as JLayeredPane, should override this method to return false.
Return
always returns true
Returns true if the component is currently painting a tile. If this method returns true, paint will be called again for another tile. This method returns false if you are not painting a tile or if the last tile is painted. Use this method to keep some state you might need between tiles.
Return
true if the component is currently painting a tile, false otherwise
Returns true if the preferred size has been set to a non-null value otherwise returns false.
Return
true if setPreferredSize has been invoked with a non-null value.
@since
1.5
Returns true if this JComponent should get focus; otherwise returns false.

Please see How to Use the Focus Subsystem, a section in The Java Tutorial, for more information.

Return
true if this component should get focus, otherwise returns false
Returns true if the specified index is in the valid range of rows, and the row at that index is selected.
Return
true if row is a valid index and the row at that index is selected (where 0 is the first row)
Determines whether this component is showing on screen. This means that the component must be visible, and it must be in a container that is visible and showing.
Return
true if the component is showing, false otherwise
@since
JDK1.0
See Also
Determines whether this component is valid. A component is valid when it is correctly sized and positioned within its parent container and all its children are also valid. In order to account for peers' size requirements, components are invalidated before they are first shown on the screen. By the time the parent container is fully realized, all its components will be valid.
Return
true if the component is valid, false otherwise
@since
JDK1.0
If this method returns true, revalidate calls by descendants of this component will cause the entire tree beginning with this root to be validated. Returns false by default. JScrollPane overrides this method and returns true.
Determines whether this component should be visible when its parent is visible. Components are initially visible, with the exception of top level components such as Frame objects.
Return
true if the component is visible, false otherwise
@since
JDK1.0
See Also
@deprecated
As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).
@deprecated
As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).
@deprecated
As of JDK version 1.1, replaced by doLayout().
Prints a listing of this component to the standard system output stream System.out.
@since
JDK1.0
Prints a listing of this component to the specified output stream.
Parameters
outa print stream
@since
JDK1.0
Prints a listing of this container to the specified output stream. The listing starts at the specified indentation.

The immediate children of the container are printed with an indentation of indent+1. The children of those children are printed at indent+2 and so on.

Parameters
outa print stream
indentthe number of spaces to indent
@since
JDK1.0
Prints a listing to the specified print writer.
Parameters
outthe print writer to print to
@since
JDK1.1
Prints out a list, starting at the specified indentation, to the specified print writer.

The immediate children of the container are printed with an indentation of indent+1. The children of those children are printed at indent+2 and so on.

Parameters
outa print writer
indentthe number of spaces to indent
@since
JDK1.1
@deprecated
As of JDK version 1.1, replaced by getComponentAt(int, int).
@deprecated
As of JDK version 1.1, replaced by getLocation().
@deprecated
As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).
@deprecated
As of JDK version 1.1, replaced by getMinimumSize().
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).
@deprecated
As of JDK version 1.1, replaced by setLocation(int, int).
Moves the column column to the position currently occupied by the column targetColumn in the view. The old column at targetColumn is shifted left or right to make room.
Parameters
columnthe index of column to be moved
targetColumnthe new index of the column
@deprecated
As of JDK version 1.1, replaced by transferFocus().
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Invoked by Swing to draw components. Applications should not invoke paint directly, but should instead use the repaint method to schedule the component for redrawing.

This method actually delegates the work of painting to three protected methods: paintComponent, paintBorder, and paintChildren. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking, the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method, as always. A subclass that just wants to specialize the UI (look and feel) delegate's paint method should just override paintComponent.

Parameters
gthe Graphics context in which to paint
Paints this component and all of its subcomponents.

The origin of the graphics context, its (00) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.

Parameters
gthe graphics context to use for painting
@since
JDK1.0
See Also
Paints each of the components in this container.
Parameters
gthe graphics context.
Paints the specified region in this component and all of its descendants that overlap the region, immediately.

It's rarely necessary to call this method. In most cases it's more efficient to call repaint, which defers the actual painting and can collapse redundant requests into a single paint call. This method is useful if one needs to update the display while the current event is being dispatched.

Parameters
xthe x value of the region to be painted
ythe y value of the region to be painted
wthe width of the region to be painted
hthe height of the region to be painted
See Also
Paints the specified region now.
Parameters
ra Rectangle containing the region to be painted
@deprecated
As of JDK version 1.1, replaced by dispatchEvent(AWTEvent).
@deprecated
As of JDK version 1.1, replaced by getPreferredSize().
Prepares the editor by querying the data model for the value and selection state of the cell at row, column.

Note: Throughout the table package, the internal implementations always use this method to prepare editors so that this default behavior can be safely overridden by a subclass.

Parameters
editorthe TableCellEditor to set up
rowthe row of the cell to edit, where 0 is the first row
columnthe column of the cell to edit, where 0 is the first column
Return
the Component being edited
Prepares an image for rendering on this component. The image data is downloaded asynchronously in another thread and the appropriate screen representation of the image is generated.
Parameters
imagethe Image for which to prepare a screen representation
observerthe ImageObserver object to be notified as the image is being prepared
Return
true if the image has already been fully prepared; false otherwise
@since
JDK1.0
Prepares an image for rendering on this component at the specified width and height.

The image data is downloaded asynchronously in another thread, and an appropriately scaled screen representation of the image is generated.

Parameters
imagethe instance of Image for which to prepare a screen representation
widththe width of the desired screen representation
heightthe height of the desired screen representation
observerthe ImageObserver object to be notified as the image is being prepared
Return
true if the image has already been fully prepared; false otherwise
@since
JDK1.0
Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

Note: Throughout the table package, the internal implementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass.

Parameters
rendererthe TableCellRenderer to prepare
rowthe row of the cell to render, where 0 is the first row
columnthe column of the cell to render, where 0 is the first column
Return
the Component under the event location
A convenience method that displays a printing dialog, and then prints this JTable in mode PrintMode.FIT_WIDTH, with no header or footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

Note: In headless mode, no dialogs will be shown.

Return
true, unless printing is cancelled by the user
Throws
PrinterExceptionif an error in the print system causes the job to be aborted
@since
1.5
Invoke this method to print the component. This method will result in invocations to printComponent, printBorder and printChildren. It is not recommended that you override this method, instead override one of the previously mentioned methods. This method sets the component's state such that the double buffer will not be used, eg painting will be done directly on the passed in Graphics.
Parameters
gthe Graphics context in which to paint
A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with no header or footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

Note: In headless mode, no dialogs will be shown.

Parameters
printModethe printing mode that the printable should use
Return
true, unless printing is cancelled by the user
Throws
PrinterExceptionif an error in the print system causes the job to be aborted
@since
1.5
A convenience method that displays a printing dialog, and then prints this JTable in the given printing mode, with the specified header and footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

Note: In headless mode, no dialogs will be shown.

Parameters
printModethe printing mode that the printable should use
headerFormata MessageFormat specifying the text to be used in printing a header, or null for none
footerFormata MessageFormat specifying the text to be used in printing a footer, or null for none
Return
true, unless printing is cancelled by the user
Throws
PrinterExceptionif an error in the print system causes the job to be aborted
@since
1.5
Print this JTable. Takes steps that the majority of developers would take in order to print a JTable. In short, it prepares the table, calls getPrintable to fetch an appropriate Printable, and then sends it to the printer.

A boolean parameter allows you to specify whether or not a printing dialog is displayed to the user. When it is, the user may use the dialog to change printing attributes or even cancel the print. Another parameter allows for printing attributes to be specified directly. This can be used either to provide the initial values for the print dialog, or to supply any needed attributes when the dialog is not shown.

A second boolean parameter allows you to specify whether or not to perform printing in an interactive mode. If true, a modal progress dialog, with an abort option, is displayed for the duration of printing . This dialog also prevents any user action which may affect the table. However, it can not prevent the table from being modified by code (for example, another thread that posts updates using SwingUtilities.invokeLater). It is therefore the responsibility of the developer to ensure that no other code modifies the table in any way during printing (invalid modifications include changes in: size, renderers, or underlying data). Printing behavior is undefined when the table is changed during printing.

If false is specified for this parameter, no dialog will be displayed and printing will begin immediately on the event-dispatch thread. This blocks any other events, including repaints, from being processed until printing is complete. Although this effectively prevents the table from being changed, it doesn't provide a good user experience. For this reason, specifying false is only recommended when printing from an application with no visible GUI.

Note: Attempting to show the printing dialog or run interactively, while in headless mode, will result in a HeadlessException.

Before fetching the printable, this method prepares the table in order to get the most desirable printed result. If the table is currently in an editing mode, it terminates the editing as gracefully as possible. It also ensures that the the table's current selection and focused cell are not indicated in the printed output. This is handled on the view level, and only for the duration of the printing, thus no notification needs to be sent to the selection models.

See #getPrintable for further description on how the table is printed.

Parameters
printModethe printing mode that the printable should use
headerFormata MessageFormat specifying the text to be used in printing a header, or null for none
footerFormata MessageFormat specifying the text to be used in printing a footer, or null for none
showPrintDialogwhether or not to display a print dialog
attra PrintRequestAttributeSet specifying any printing attributes, or null for none
interactivewhether or not to print in an interactive mode
Return
true, unless printing is cancelled by the user
Throws
PrinterExceptionif an error in the print system causes the job to be aborted
HeadlessExceptionif the method is asked to show a printing dialog or run interactively, and GraphicsEnvironment.isHeadless returns true
@since
1.5
Invoke this method to print the component. This method invokes print on the component.
Parameters
gthe Graphics context in which to paint
Prints each of the components in this container.
Parameters
gthe graphics context.
Adds an arbitrary key/value "client property" to this component.

The get/putClientProperty methods provide access to a small per-instance hashtable. Callers can use get/putClientProperty to annotate components that were created by another module. For example, a layout manager might store per child constraints this way. For example:

 componentA.putClientProperty("to the left of", componentB);
 
If value is null this method will remove the property. Changes to client properties are reported with PropertyChange events. The name of the property (for the sake of PropertyChange events) is key.toString().

The clientProperty dictionary is not intended to support large scale extensions to JComponent nor should be it considered an alternative to subclassing when designing a new component.

Parameters
keythe new client property key
valuethe new client property value; if null this method will remove the property
This method is now obsolete, please use a combination of getActionMap() and getInputMap() for similiar behavior.
This method is now obsolete, please use a combination of getActionMap() and getInputMap() for similiar behavior. For example, to bind the KeyStroke aKeyStroke to the Action anAction now use:
   component.getInputMap().put(aKeyStroke, aCommand);
   component.getActionMap().put(aCommmand, anAction);
 
The above assumes you want the binding to be applicable for WHEN_FOCUSED. To register bindings for other focus states use the getInputMap method that takes an integer.

Register a new keyboard action. anAction will be invoked if a key event matching aKeyStroke occurs and aCondition is verified. The KeyStroke object defines a particular combination of a keyboard key and one or more modifiers (alt, shift, ctrl, meta).

The aCommand will be set in the delivered event if specified.

The aCondition can be one of:

WHEN_FOCUSED
The action will be invoked only when the keystroke occurs while the component has the focus.
WHEN_IN_FOCUSED_WINDOW
The action will be invoked when the keystroke occurs while the component has the focus or if the component is in the window that has the focus. Note that the component need not be an immediate descendent of the window -- it can be anywhere in the window's containment hierarchy. In other words, whenever any component in the window has the focus, the action registered with this component is invoked.
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
The action will be invoked when the keystroke occurs while the component has the focus or if the component is an ancestor of the component that has the focus.

The combination of keystrokes and conditions lets you define high level (semantic) action events for a specified keystroke+modifier combination (using the KeyStroke class) and direct to a parent or child of a component that has the focus, or to the component itself. In other words, in any hierarchical structure of components, an arbitrary key-combination can be immediately directed to the appropriate component in the hierarchy, and cause a specific method to be invoked (usually by way of adapter objects).

If an action has already been registered for the receiving container, with the same charCode and the same modifiers, anAction will replace the action.

Parameters
anActionthe Action to be registered
aCommandthe command to be set in the delivered event
aKeyStrokethe KeyStroke to bind to the action
aConditionthe condition that needs to be met, see above
See Also
Removes the specified component from this container. This method also notifies the layout manager to remove the component from this container's layout via the removeLayoutComponent method.
Parameters
compthe component to be removed
See Also
Removes the component, specified by index, from this container. This method also notifies the layout manager to remove the component from this container's layout via the removeLayoutComponent method.
Parameters
indexthe index of the component to be removed
@since
JDK1.1
See Also
Removes the specified popup menu from the component.
Parameters
popupthe popup menu to be removed
@since
JDK1.1
Removes all the components from this container. This method also notifies the layout manager to remove the components from this container's layout via the removeLayoutComponent method.
See Also
Unregisters listener so that it will no longer receive AncestorEvents.
Parameters
listenerthe AncestorListener to be removed
Removes aColumn from this 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 responsible for displaying it.
Parameters
aColumnthe TableColumn to be removed
See Also
Deselects the columns from index0 to index1, inclusive.
Parameters
index0one end of the interval
index1the other end of the interval
Throws
IllegalArgumentExceptionif index0 or index1 lie outside [0, getColumnCount()-1]
Removes the specified component listener so that it no longer receives component events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified container listener so it no longer receives container events from this container. If l is null, no exception is thrown and no action is performed.
Parameters
lthe container listener
Discards the editor object and frees the real estate it used for cell rendering.
Removes the specified focus listener so that it no longer receives focus events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe focus listener
@since
JDK1.1
Removes the specified hierarchy bounds listener so that it no longer receives hierarchy bounds events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified hierarchy listener so that it no longer receives hierarchy changed events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified input method listener so that it no longer receives input method events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified key listener so that it no longer receives key events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe key listener
@since
JDK1.1
Removes the specified mouse listener so that it no longer receives mouse events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Parameters
lthe mouse listener
@since
JDK1.1
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.
Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If l is null, no exception is thrown and no action is performed.
Calls the unconfigureEnclosingScrollPane method.
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If propertyName or listener is null, no exception is thrown and no action is taken.

Deselects the rows from index0 to index1, inclusive.
Parameters
index0one end of the interval
index1the other end of the interval
Throws
IllegalArgumentExceptionif index0 or index1 lie outside [0, getRowCount()-1]
Removes a VetoableChangeListener from the listener list. This removes a VetoableChangeListener that was registered for all properties.
Parameters
listenerthe VetoableChangeListener to be removed
Repaints this component.

If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

@since
JDK1.0
Repaints the specified rectangle of this component.

If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

Parameters
xthe x coordinate
ythe y coordinate
widththe width
heightthe height
@since
JDK1.0
Repaints the component. If this component is a lightweight component, this results in a call to paint within tm milliseconds.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

Parameters
tmmaximum time in milliseconds before update
@since
JDK1.0
Adds the specified region to the dirty region list if the component is showing. The component will be repainted after all of the currently pending events have been dispatched.
Parameters
tmthis parameter is not used
xthe x value of the dirty region
ythe y value of the dirty region
widththe width of the dirty region
heightthe height of the dirty region
Adds the specified region to the dirty region list if the component is showing. The component will be repainted after all of the currently pending events have been dispatched.
Parameters
ra Rectangle containing the dirty region
In release 1.4, the focus subsystem was rearchitected. For more information, see How to Use the Focus Subsystem, a section in The Java Tutorial.

Requests focus on this JComponent's FocusTraversalPolicy's default Component. If this JComponent is a focus cycle root, then its FocusTraversalPolicy is used. Otherwise, the FocusTraversalPolicy of this JComponent's focus-cycle-root ancestor is used.

@deprecated
As of 1.4, replaced by FocusTraversalPolicy.getDefaultComponent(Container).requestFocus()
Requests that this Component gets the input focus. Refer to Component.requestFocus() for a complete description of this method.

Note that the use of this method is discouraged because its behavior is platform dependent. Instead we recommend the use of requestFocusInWindow() . If you would like more information on focus, see

Requests that this Component gets the input focus. Refer to Component.requestFocus(boolean) for a complete description of this method.

Note that the use of this method is discouraged because its behavior is platform dependent. Instead we recommend the use of requestFocusInWindow(boolean) . If you would like more information on focus, see How to Use the Focus Subsystem, a section in The Java Tutorial.

Parameters
temporaryboolean indicating if the focus change is temporary
Return
false if the focus change request is guaranteed to fail; true if it is likely to succeed
@since
1.4
Requests that this Component gets the input focus. Refer to Component.requestFocusInWindow() for a complete description of this method.

If you would like more information on focus, see How to Use the Focus Subsystem, a section in The Java Tutorial.

Return
false if the focus change request is guaranteed to fail; true if it is likely to succeed
@since
1.4
Unregisters all the bindings in the first tier InputMaps and ActionMap. This has the effect of removing any local bindings, and allowing the bindings defined in parent InputMap/ActionMaps (the UI is usually defined in the second tier) to persist.
Parameters
xthe new horizontal location
ythe new vertical location
wthe new width
hthe new height
@deprecated
As of JDK 5, replaced by Component.setBounds(int, int, int, int).

Moves and resizes this component.

@deprecated
As of JDK version 1.1, replaced by setSize(Dimension).
@deprecated
As of JDK version 1.1, replaced by setSize(int, int).
Supports deferred automatic layout.

Calls invalidate and then adds this component's validateRoot to a list of components that need to be validated. Validation will occur after all currently pending events have been dispatched. In other words after this method is called, the first validateRoot (if any) found when walking up the containment hierarchy of this component will be validated. By default, JRootPane, JScrollPane, and JTextField return true from isValidateRoot.

This method will automatically be called on this component when a property value changes such that size, location, or internal layout of this component has been affected. This automatic updating differs from the AWT because programs generally no longer need to invoke validate to get the contents of the GUI to update.

Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].
Parameters
pointthe location of interest
Return
the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1]
Forwards the scrollRectToVisible() message to the JComponent's parent. Components that can service the request, such as JViewport, override this method and perform the scrolling.
Parameters
aRectthe visible Rectangle
See Also
Selects all rows, columns, and cells in the table.
Sets the ActionMap to am. This does not set the parent of the am to be the ActionMap from the UI (if there was one), it is up to the caller to have done this.
Parameters
amthe new ActionMap
@since
1.3
Sets the the vertical alignment.
Parameters
alignmentXthe new vertical alignment
@beaninfo
description: The preferred horizontal alignment of the component.
Sets the the horizontal alignment.
Parameters
alignmentYthe new horizontal alignment
@beaninfo
description: The preferred vertical alignment of the component.
Sets this table's autoCreateColumnsFromModel flag. This method calls createDefaultColumnsFromModel if autoCreateColumnsFromModel changes from false to true.
Parameters
autoCreateColumnsFromModeltrue if JTable should automatically create columns
@beaninfo
bound: true description: Automatically populates the columnModel when a new TableModel is submitted.
Sets the table's auto resize mode when the table is resized.
Parameters
modeOne of 5 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS
@beaninfo
bound: true description: Whether the columns should adjust themselves automatically. enum: AUTO_RESIZE_OFF JTable.AUTO_RESIZE_OFF AUTO_RESIZE_NEXT_COLUMN JTable.AUTO_RESIZE_NEXT_COLUMN AUTO_RESIZE_SUBSEQUENT_COLUMNS JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS AUTO_RESIZE_LAST_COLUMN JTable.AUTO_RESIZE_LAST_COLUMN AUTO_RESIZE_ALL_COLUMNS JTable.AUTO_RESIZE_ALL_COLUMNS
Sets the autoscrolls property. If true mouse dragged events will be synthetically generated when the mouse is dragged outside of the component's bounds and mouse motion has paused (while the button continues to be held down). The synthetic events make it appear that the drag gesture has resumed in the direction established when the component's boundary was crossed. Components that support autoscrolling must handle mouseDragged events by calling scrollRectToVisible with a rectangle that contains the mouse event's location. All of the Swing components that support item selection and are typically displayed in a JScrollPane (JTable, JList, JTree, JTextArea, and JEditorPane) already handle mouse dragged events in this way. To enable autoscrolling in any other component, add a mouse motion listener that calls scrollRectToVisible. For example, given a JPanel, myPanel:
 MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
     public void mouseDragged(MouseEvent e) {
        Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
        ((JPanel)e.getSource()).scrollRectToVisible(r);
    }
 };
 myPanel.addMouseMotionListener(doScrollRectToVisible);
 
The default value of the autoScrolls property is false.
Parameters
autoscrollsif true, synthetic mouse dragged events are generated when the mouse is dragged outside of a component's bounds and the mouse button continues to be held down; otherwise false
@beaninfo
expert: true description: Determines if this component automatically scrolls its contents when dragged.
Sets the background color of this component.
Parameters
bgthe desired background Color
@beaninfo
preferred: true bound: true attribute: visualUpdate true description: The background color of the component.
Sets the border of this component. The Border object is responsible for defining the insets for the component (overriding any insets set directly on the component) and for optionally rendering any border decorations within the bounds of those insets. Borders should be used (rather than insets) for creating both decorative and non-decorative (such as margins and padding) regions for a swing component. Compound borders can be used to nest multiple borders within a single component.

Although technically you can set the border on any object that inherits from JComponent, the look and feel implementation of many standard Swing components doesn't work well with user-set borders. In general, when you want to set a border on a standard Swing component other than JPanel or JLabel, we recommend that you put the component in a JPanel and set the border on the JPanel.

This is a bound property.

Parameters
borderthe border to be rendered for this component
@beaninfo
bound: true preferred: true attribute: visualUpdate true description: The component's border.
Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.
Parameters
xthe new x-coordinate of this component
ythe new y-coordinate of this component
widththe new width of this component
heightthe new height of this component
@since
JDK1.1
Moves and resizes this component to conform to the new bounding rectangle r. This component's new position is specified by r.x and r.y, and its new size is specified by r.width and r.height
Parameters
rthe new bounding rectangle for this component
@since
JDK1.1
Sets the cellEditor variable.
Parameters
anEditorthe TableCellEditor that does the editing
@beaninfo
bound: true description: The table's active cell editor, if one exists.
See Also
Sets whether this table allows both a column selection and a row selection to exist simultaneously. When set, the table treats the intersection of the row and column selection models as the selected cells. Override isCellSelected to change this default behavior. This method is equivalent to setting both the rowSelectionAllowed property and columnSelectionAllowed property of the columnModel to the supplied value.
Parameters
cellSelectionEnabledtrue if simultaneous row and column selection is allowed
@beaninfo
bound: true attribute: visualUpdate true description: Select a rectangular region of cells rather than rows or columns.
Sets the column model for this table to newModel and registers for listener notifications from the new column model. Also sets the column model of the JTableHeader to columnModel.
Parameters
columnModelthe new data source for this table
Throws
IllegalArgumentExceptionif columnModel is null
@beaninfo
bound: true description: The object governing the way columns appear in the view.
Sets whether the columns in this model can be selected.
Parameters
columnSelectionAllowedtrue if this model will allow column selection
@beaninfo
bound: true attribute: visualUpdate true description: If true, an entire column is selected for each selected cell.
Selects the columns from index0 to index1, inclusive.
Parameters
index0one end of the interval
index1the other end of the interval
Throws
IllegalArgumentExceptionif index0 or index1 lie outside [0, getColumnCount()-1]
Sets the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitive LayoutManager and Component subclasses will use this property to determine how to lay out and draw components.

At construction time, a component's orientation is set to ComponentOrientation.UNKNOWN, indicating that it has not been specified explicitly. The UNKNOWN orientation behaves the same as ComponentOrientation.LEFT_TO_RIGHT.

To set the orientation of a single component, use this method. To set the orientation of an entire component hierarchy, use applyComponentOrientation .

@author
Laura Werner, IBM
@beaninfo
bound: true
Sets the JPopupMenu for this JComponent. The UI is responsible for registering bindings and adding the necessary listeners such that the JPopupMenu will be shown at the appropriate time. When the JPopupMenu is shown depends upon the look and feel: some may show it on a mouse event, some may enable a key binding.

If popup is null, and getInheritsPopupMenu returns true, then getComponentPopupMenu will be delegated to the parent. This provides for a way to make all child components inherit the popupmenu of the parent.

This is a bound property.

Parameters
popup- the popup that will be assigned to this component may be null
@beaninfo
bound: true preferred: true description: Popup to show
@since
1.5
Moves the specified component to the specified z-order index in the container. The z-order determines the order that components are painted; the component with the highest z-order paints first and the component with the lowest z-order paints last. Where components overlap, the component with the lower z-order paints over the component with the higher z-order.

If the component is a child of some other container, it is removed from that container before being added to this container. The important difference between this method and java.awt.Container.add(Component, int) is that this method doesn't call removeNotify on the component while removing it from its previous container unless necessary and when allowed by the underlying native windowing system. This way, if the component has the keyboard focus, it maintains the focus when moved to the new position.

This property is guaranteed to apply only to lightweight non-Container components.

Note: Not all platforms support changing the z-order of heavyweight components from one container into another without the call to removeNotify. There is no way to detect whether a platform supports this, so developers shouldn't make any assumptions.

Parameters
compthe component to be moved
indexthe position in the container's list to insert the component, where getComponentCount() appends to the end
Throws
NullPointerExceptionif comp is null
IllegalArgumentExceptionif comp is one of the container's parents
IllegalArgumentExceptionif index is not in the range [0, getComponentCount()] for moving between containers, or not in the range [0, getComponentCount()-1] for moving inside a container
IllegalArgumentExceptionif adding a container to itself
IllegalArgumentExceptionif adding a Window to a container
@since
1.5
Sets the cursor image to the specified cursor. This cursor image is displayed when the contains method for this component returns true for the current cursor location, and this Component is visible, displayable, and enabled. Setting the cursor of a Container causes that cursor to be displayed within all of the container's subcomponents, except for those that have a non-null cursor.
Parameters
cursorOne of the constants defined by the Cursor class; if this parameter is null then this component will inherit the cursor of its parent
@since
JDK1.1
Enables or disables diagnostic information about every graphics operation performed within the component or one of its children.
Parameters
debugOptionsdetermines how the component should display the information; one of the following options:
  • DebugGraphics.LOG_OPTION - causes a text message to be printed.
  • DebugGraphics.FLASH_OPTION - causes the drawing to flash several times.
  • DebugGraphics.BUFFERED_OPTION - creates an ExternalWindow that displays the operations performed on the View's offscreen buffer.
  • DebugGraphics.NONE_OPTION disables debugging.
  • A value of 0 causes no changes to the debugging options.
debugOptions is bitwise OR'd into the current value
@beaninfo
preferred: true enum: NONE_OPTION DebugGraphics.NONE_OPTION LOG_OPTION DebugGraphics.LOG_OPTION FLASH_OPTION DebugGraphics.FLASH_OPTION BUFFERED_OPTION DebugGraphics.BUFFERED_OPTION description: Diagnostic options for graphics operations.
Sets a default cell 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, uses the isCellEditable method in the TableModel interface to ensure that this JTable will not start an editor in these columns. If editor is null, removes the default editor for this column class.
Parameters
columnClassset the default cell editor for this columnClass
editordefault cell editor to be used for this columnClass
Sets the default locale used to initialize each JComponent's locale property upon creation. The initial value is the VM's default locale. The default locale has "AppContext" scope so that applets (and potentially multiple lightweight applications running in a single VM) can have their own setting. An applet can safely alter its default locale because it will have no affect on other applets (or the browser).
Parameters
lthe desired default Locale for new components.
@since
1.4
Sets a default cell renderer to be used if no renderer has been set in a TableColumn. If renderer is null, removes the default renderer for this column class.
Parameters
columnClassset the default cell renderer for this columnClass
rendererdefault cell renderer to be used for this columnClass
Sets whether the this component should use a buffer to paint. If set to true, all the drawing from this component will be done in an offscreen painting buffer. The offscreen painting buffer will the be copied onto the screen. Swings painting system always uses a maximum of one double buffer. If a Component is buffered and one of its ancestor is also buffered, the ancestor buffer will be used.
Parameters
aFlagif true, set this component to be double buffered
Sets the dragEnabled property, which must be true to enable automatic drag handling (the first part of drag and drop) on this component. The transferHandler property needs to be set to a non-null value for the drag to do anything. The default value of the dragEnabledfalse.

When automatic drag handling is enabled, most look and feels begin a drag-and-drop operation whenever the user presses the mouse button over a selection and then moves the mouse a few pixels. Setting this property to true can therefore have a subtle effect on how selections behave.

Some look and feels might not support automatic drag and drop; they will ignore this property. You can work around such look and feels by modifying the component to directly call the exportAsDrag method of a TransferHandler.

Parameters
bthe value to set the dragEnabled property to
Throws
HeadlessExceptionif b is true and GraphicsEnvironment.isHeadless() returns true
@since
1.4
@beaninfo
description: determines whether automatic drag handling is enabled bound: false
Associate a DropTarget with this component. The Component will receive drops only if it is enabled.
Parameters
dtThe DropTarget
See Also
Sets the editingColumn variable.
Parameters
aColumnthe column of the cell to be edited
Sets the editingRow variable.
Parameters
aRowthe row of the cell to be edited
See Also
Sets whether or not this component is enabled. A component that is enabled may respond to user input, while a component that is not enabled cannot respond to user input. Some components may alter their visual representation when they are disabled in order to provide feedback to the user that they cannot take input.

Note: Disabling a component does not disable it's children.

Note: Disabling a lightweight component does not prevent it from receiving MouseEvents.

Parameters
enabledtrue if this component should be enabled, false otherwise
@beaninfo
preferred: true bound: true attribute: visualUpdate true description: The enabled state of the component.
Sets the focusable state of this Component to the specified value. This value overrides the Component's default focusability.
Parameters
focusableindicates whether this Component is focusable
@since
1.4
@beaninfo
bound: true
See Also
Sets whether this Container is the root of a focus traversal cycle. Once focus enters a traversal cycle, typically it cannot leave it via focus traversal unless one of the up- or down-cycle keys is pressed. Normal traversal is limited to this Container, and all of this Container's descendants that are not descendants of inferior focus cycle roots. Note that a FocusTraversalPolicy may bend these restrictions, however. For example, ContainerOrderFocusTraversalPolicy supports implicit down-cycle traversal.

The alternative way to specify the traversal order of this Container's children is to make this Container a focus traversal policy provider.

Parameters
focusCycleRootindicates whether this Container is the root of a focus traversal cycle
@since
1.4
@beaninfo
bound: true
Sets the focus traversal keys for a given traversal operation for this Component. Refer to java.awt.Component#setFocusTraversalKeys for a complete description of this method.
Parameters
idone of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
keystrokesthe Set of AWTKeyStroke for the specified operation
Throws
IllegalArgumentExceptionif id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or if keystrokes contains null, or if any Object in keystrokes is not an AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any keystroke already maps to another focus traversal operation for this Component
@since
1.5
@beaninfo
bound: true
Sets whether focus traversal keys are enabled for this Component. Components for which focus traversal keys are disabled receive key events for focus traversal keys. Components for which focus traversal keys are enabled do not see these events; instead, the events are automatically converted to traversal operations.
Parameters
focusTraversalKeysEnabledwhether focus traversal keys are enabled for this Component
@since
1.4
@beaninfo
bound: true
Sets the focus traversal policy that will manage keyboard traversal of this Container's children, if this Container is a focus cycle root. If the argument is null, this Container inherits its policy from its focus- cycle-root ancestor. If the argument is non-null, this policy will be inherited by all focus-cycle-root children that have no keyboard- traversal policy of their own (as will, recursively, their focus-cycle- root children).

If this Container is not a focus cycle root, the policy will be remembered, but will not be used or inherited by this or any other Containers until this Container is made a focus cycle root.

Parameters
policythe new focus traversal policy for this Container
@since
1.4
@beaninfo
bound: true
Sets whether this container will be used to provide focus traversal policy. Container with this property as true will be used to acquire focus traversal policy instead of closest focus cycle root ancestor.
Parameters
provideindicates whether this container will be used to provide focus traversal policy
@since
1.5
@beaninfo
bound: true
Sets the font for this component.
Parameters
fontthe desired Font for this component
@beaninfo
preferred: true bound: true attribute: visualUpdate true description: The font for the component.
Sets the foreground color of this component.
Parameters
fgthe desired foreground Color
@beaninfo
preferred: true bound: true attribute: visualUpdate true description: The foreground color of the component.
Sets the color used to draw grid lines to gridColor and redisplays. The default color is look and feel dependent.
Parameters
gridColorthe new color of the grid lines
Throws
IllegalArgumentExceptionif gridColor is null
@beaninfo
bound: true description: The grid color.
See Also
Sets whether or not paint messages received from the operating system should be ignored. This does not affect paint events generated in software by the AWT, unless they are an immediate response to an OS-level paint message.

This is useful, for example, if running under full-screen mode and better performance is desired, or if page-flipping is used as the buffer strategy.

Sets whether or not getComponentPopupMenu should delegate to the parent if this component does not have a JPopupMenu assigned to it.

The default value for this is false, but some JComponent subclasses that are implemented as a number of JComponents may set this to true.

This is a bound property.

Parameters
valuewhether or not the JPopupMenu is inherited
@beaninfo
bound: true description: Whether or not the JPopupMenu is inherited
@since
1.5
Sets the InputMap to use under the condition condition to map. A null value implies you do not want any bindings to be used, even from the UI. This will not reinstall the UI InputMap (if there was one). condition has one of the following values:
  • WHEN_IN_FOCUSED_WINDOW
  • WHEN_FOCUSED
  • WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
If condition is WHEN_IN_FOCUSED_WINDOW and map is not a ComponentInputMap, an IllegalArgumentException will be thrown. Similarly, if condition is not one of the values listed, an IllegalArgumentException will be thrown.
Parameters
conditionone of the values listed above
mapthe InputMap to use for the given condition
Throws
IllegalArgumentExceptionif condition is WHEN_IN_FOCUSED_WINDOW and map is not an instance of ComponentInputMap; or if condition is not one of the legal values specified above
@since
1.3
Sets the input verifier for this component.
Parameters
inputVerifierthe new input verifier
@since
1.3
@beaninfo
bound: true description: The component's input verifier.
See Also
Sets the rowMargin and the columnMargin -- the height and width of the space between cells -- to intercellSpacing.
Parameters
intercellSpacinga Dimension specifying the new width and height between cells
@beaninfo
description: The spacing between the cells, drawn in the background color of the JTable.
Sets the layout manager for this container.
Parameters
mgrthe specified layout manager
Sets the locale of this component. This is a bound property.
Parameters
lthe locale to become this component's locale
@since
JDK1.1
See Also
Moves this component to a new location. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent.
Parameters
xthe x-coordinate of the new location's top-left corner in the parent's coordinate space
ythe y-coordinate of the new location's top-left corner in the parent's coordinate space
@since
JDK1.1
Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space.
Parameters
pthe point defining the top-left corner of the new location, given in the coordinate space of this component's parent
@since
JDK1.1
Sets the maximum size of this component to a constant value. Subsequent calls to getMaximumSize will always return this value; the component's UI will not be asked to compute it. Setting the maximum size to null restores the default behavior.
Parameters
maximumSizea Dimension containing the desired maximum allowable size
@beaninfo
bound: true description: The maximum size of the component.
Sets the minimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value; the component's UI will not be asked to compute it. Setting the minimum size to null restores the default behavior.
Parameters
minimumSizethe new minimum size of this component
@beaninfo
bound: true description: The minimum size of the component.
Sets the data model for this table to newModel and registers with it for listener notifications from the new data model.
Parameters
dataModelthe new data source for this table
Throws
IllegalArgumentExceptionif newModel is null
@beaninfo
bound: true description: The model that is the source of the data for this view.
See Also
Sets the name of the component to the specified string.
Parameters
namethe string that is to be this component's name
@since
JDK1.1
See Also
In release 1.4, the focus subsystem was rearchitected. For more information, see How to Use the Focus Subsystem, a section in The Java Tutorial.

Overrides the default FocusTraversalPolicy for this JComponent's focus traversal cycle by unconditionally setting the specified Component as the next Component in the cycle, and this JComponent as the specified Component's previous Component in the cycle.

Parameters
aComponentthe Component that should follow this JComponent in the focus traversal cycle
@deprecated
As of 1.4, replaced by FocusTraversalPolicy
If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through.

The default value of this property is false for JComponent. However, the default value for this property on most standard JComponent subclasses (such as JButton and JTree) is look-and-feel dependent.

Parameters
isOpaquetrue if this component should be opaque
@beaninfo
bound: true expert: true description: The component's opacity
See Also
Sets the preferred size of the viewport for this table.
Parameters
sizea Dimension object specifying the preferredSize of a JViewport whose view is this table
@beaninfo
description: The preferred size of the viewport.
Sets the preferred size of this component. If preferredSize is null, the UI will be asked for the preferred size.
@beaninfo
preferred: true bound: true description: The preferred size of the component.
Provides a hint as to whether or not this JComponent should get focus. This is only a hint, and it is up to consumers that are requesting focus to honor this property. This is typically honored for mouse operations, but not keyboard operations. For example, look and feels could verify this property is true before requesting focus during a mouse operation. This would often times be used if you did not want a mouse press on a JComponent to steal focus, but did want the JComponent to be traversable via the keyboard. If you do not want this JComponent focusable at all, use the setFocusable method instead.

Please see How to Use the Focus Subsystem, a section in The Java Tutorial, for more information.

Parameters
requestFocusEnabledindicates whether you want this JComponent to be focusable or not
Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints. The height of the cells will be equal to the row height minus the row margin.
Parameters
rowHeightnew row height
Throws
IllegalArgumentExceptionif rowHeight is less than 1
@beaninfo
bound: true description: The height of the specified row.
See Also
Sets the height for row to rowHeight, revalidates, and repaints. The height of the cells in this row will be equal to the row height minus the row margin.
Parameters
rowthe row whose height is being changed
rowHeightnew row height, in pixels
Throws
IllegalArgumentExceptionif rowHeight is less than 1
@beaninfo
bound: true description: The height in pixels of the cells in row
Sets the amount of empty space between cells in adjacent rows.
Parameters
rowMarginthe number of pixels between cells in a row
@beaninfo
bound: true description: The amount of space between cells.
See Also
Sets whether the rows in this model can be selected.
Parameters
rowSelectionAllowedtrue if this model will allow row selection
@beaninfo
bound: true attribute: visualUpdate true description: If true, an entire row is selected for each selected cell.
Selects the rows from index0 to index1, inclusive.
Parameters
index0one end of the interval
index1the other end of the interval
Throws
IllegalArgumentExceptionif index0 or index1 lie outside [0, getRowCount()-1]
Sets 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.

This is a JavaBeans bound property.

Parameters
selectionBackgroundthe Color to use for the background of selected cells
@beaninfo
bound: true description: A default background color for selected cells.
Sets 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.

This is a JavaBeans bound property.

Parameters
selectionForegroundthe Color to use in the foreground for selected list items
@beaninfo
bound: true description: A default foreground color for selected cells.
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 the row and column selection models operating in different modes, set them both directly.

Both the row and column selection models for JTable default to using a DefaultListSelectionModel so that JTable works the same way as the JList. See the setSelectionMode method in JList for details about the modes.

@beaninfo
description: The selection mode used by the row and column selection models. enum: SINGLE_SELECTION ListSelectionModel.SINGLE_SELECTION SINGLE_INTERVAL_SELECTION ListSelectionModel.SINGLE_INTERVAL_SELECTION MULTIPLE_INTERVAL_SELECTION ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
Sets the row selection model for this table to newModel and registers for listener notifications from the new selection model.
Parameters
newModelthe new selection model
Throws
IllegalArgumentExceptionif newModel is null
@beaninfo
bound: true description: The selection model for rows.
Sets whether the table draws grid lines around cells. If showGrid is true it does; if it is false it doesn't. There is no getShowGrid method as this state is held in two variables -- showHorizontalLines and showVerticalLines -- each of which can be queried independently.
Parameters
showGridtrue if table view should draw grid lines
@beaninfo
description: The color used to draw the grid lines.
Sets whether the table draws horizontal lines between cells. If showHorizontalLines is true it does; if it is false it doesn't.
Parameters
showHorizontalLinestrue if table view should draw horizontal lines
@beaninfo
bound: true description: Whether horizontal lines should be drawn in between the cells.
Sets whether the table draws vertical lines between cells. If showVerticalLines is true it does; if it is false it doesn't.
Parameters
showVerticalLinestrue if table view should draw vertical lines
@beaninfo
bound: true description: Whether vertical lines should be drawn in between the cells.
Resizes this component so that it has width d.width and height d.height.
Parameters
dthe dimension specifying the new size of this component
@since
JDK1.1
See Also
Resizes this component so that it has width width and height height.
Parameters
widththe new width of this component in pixels
heightthe new height of this component in pixels
@since
JDK1.1
See Also
Sets whether editors in this JTable get the keyboard focus when an editor is activated as a result of the JTable forwarding keyboard events for a cell. By default, this property is false, and the JTable retains the focus unless the cell is clicked.
Parameters
surrendersFocusOnKeystroketrue if the editor should get the focus when keystrokes cause the editor to be activated
Sets the tableHeader working with this JTable to newHeader. It is legal to have a null tableHeader.
Parameters
tableHeadernew tableHeader
@beaninfo
bound: true description: The JTableHeader instance which renders the column headers.
Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.

See How to Use Tool Tips in The Java Tutorial for further documentation.

Parameters
textthe string to display; if the text is null, the tool tip is turned off for this component
@beaninfo
preferred: true description: The text to display in a tool tip.
Sets the transferHandler property, which is null if the component does not support data transfer operations.

If newHandler is not null, and the system property suppressSwingDropSupport is not true, this will install a DropTarget on the JComponent. The default for the system property is false, so that a DropTarget will be added.

Please see How to Use Drag and Drop and Data Transfer, a section in The Java Tutorial, for more information.

Parameters
newHandlermechanism for transfer of data to and from the component
@since
1.4
@beaninfo
bound: true hidden: true description: Mechanism for transfer of data to and from the component
Sets the L&F object that renders this component and repaints.
Parameters
uithe TableUI L&F object
@beaninfo
bound: true hidden: true attribute: visualUpdate true description: The UI object that implements the Component's LookAndFeel.
Sets the value for the cell in the table model at row and 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, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering. aValue is the new value.

Parameters
aValuethe new value
rowthe row of the cell to be changed
columnthe column of the cell to be changed
See Also
Sets the value to indicate whether input verifier for the current focus owner will be called before this component requests focus. The default is true. Set to false on components such as a Cancel button or a scrollbar, which should activate even if the input in the current focus owner is not "passed" by the input verifier for that component.
Parameters
verifyInputWhenFocusTargetvalue for the verifyInputWhenFocusTarget property
@since
1.3
@beaninfo
bound: true description: Whether the Component verifies input before accepting focus.
Makes the component visible or invisible. Overrides Component.setVisible.
Parameters
aFlagtrue to make the component visible; false to make it invisible
@beaninfo
attribute: visualUpdate true
@deprecated
As of JDK version 1.1, replaced by setVisible(boolean).
@deprecated
As of JDK version 1.1, replaced by setVisible(boolean).
@deprecated
As of JDK version 1.1, replaced by getSize().
Sizes the table columns to fit the available space.
@deprecated
As of Swing version 1.0.3, replaced by doLayout().
See Also
Obsolete as of Java 2 platform v1.4. Please use the doLayout() method instead.
Parameters
resizingColumnthe column whose resizing made this adjustment necessary or -1 if there is no such column
See Also
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
Returns a string representation of this component and its values.
Return
a string representation of this component
@since
JDK1.0
Transfers the focus to the next component, as though this Component were the focus owner.
@since
JDK1.1
Transfers the focus down one focus traversal cycle. If this Container is a focus cycle root, then the focus owner is set to this Container's default Component to focus, and the current focus cycle root is set to this Container. If this Container is not a focus cycle root, then no focus traversal operation occurs.
Transfers the focus up one focus traversal cycle. Typically, the focus owner is set to this Component's focus cycle root, and the current focus cycle root is set to the new focus owner's focus cycle root. If, however, this Component's focus cycle root is a Window, then the focus owner is set to the focus cycle root's default Component to focus, and the current focus cycle root is unchanged.
This method is now obsolete. To unregister an existing binding you can either remove the binding from the ActionMap/InputMap, or place a dummy binding the InputMap. Removing the binding from the InputMap allows bindings in parent InputMaps to be active, whereas putting a dummy binding in the InputMap effectively disables the binding from ever happening.

Unregisters a keyboard action. This will remove the binding from the ActionMap (if it exists) as well as the InputMaps.

Calls paint. Doesn't clear the background but see ComponentUI.update, which is called by paintComponent.
Parameters
gthe Graphics context in which to paint
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
Validates this container and all of its subcomponents.

The validate method is used to cause a container to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information changed) after the container has been displayed.

Called whenever the value of the selection changes.
Parameters
ethe event that characterizes the change.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.