defaulttablemodel.html

来自「API資料大全」· HTML 代码 · 共 1,161 行 · 第 1/4 页

HTML
1,161
字号
<A NAME="DefaultTableModel(java.lang.Object[][], java.lang.Object[])"><!-- --></A><H3>DefaultTableModel</H3><PRE>public <B>DefaultTableModel</B>(<A HREF="../../../java/lang/Object.html">Object</A>[][]&nbsp;data,                         <A HREF="../../../java/lang/Object.html">Object</A>[]&nbsp;columnNames)</PRE><DL><DD>Constructs a <code>DefaultTableModel</code> and initializes the table  by passing <code>data</code> and <code>columnNames</code>  to the <code>setDataVector</code>  method. The first index in the <code>Object[][]</code> array is  the row index and the second is the column index.<DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - the data of the table<DD><CODE>columnNames</CODE> - the names of the columns<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#getDataVector()"><CODE>getDataVector()</CODE></A>, <A HREF="../../../javax/swing/table/DefaultTableModel.html#setDataVector(java.util.Vector, java.util.Vector)"><CODE>setDataVector(java.util.Vector, java.util.Vector)</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getDataVector()"><!-- --></A><H3>getDataVector</H3><PRE>public <A HREF="../../../java/util/Vector.html">Vector</A> <B>getDataVector</B>()</PRE><DL><DD>Returns the <code>Vector</code> of <code>Vectors</code>  that contains the table's  data values.  The vectors contained in the outer vector are  each a single row of values.  In other words, to get to the cell  at row 1, column 5: <p>  <code>((Vector)getDataVector().elementAt(1)).elementAt(5);</code><p><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the vector of vectors containing the tables data values<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#newDataAvailable(javax.swing.event.TableModelEvent)"><CODE>newDataAvailable(javax.swing.event.TableModelEvent)</CODE></A>, <A HREF="../../../javax/swing/table/DefaultTableModel.html#newRowsAdded(javax.swing.event.TableModelEvent)"><CODE>newRowsAdded(javax.swing.event.TableModelEvent)</CODE></A>, <A HREF="../../../javax/swing/table/DefaultTableModel.html#setDataVector(java.util.Vector, java.util.Vector)"><CODE>setDataVector(java.util.Vector, java.util.Vector)</CODE></A></DL></DD></DL><HR><A NAME="setDataVector(java.util.Vector, java.util.Vector)"><!-- --></A><H3>setDataVector</H3><PRE>public void <B>setDataVector</B>(<A HREF="../../../java/util/Vector.html">Vector</A>&nbsp;newData,                          <A HREF="../../../java/util/Vector.html">Vector</A>&nbsp;columnNames)</PRE><DL><DD>Replaces the current <code>dataVector</code> instance variable with the  new Vector of rows, <code>newData</code>.  <code>columnNames</code> are the names  of the new columns.  The first name in <code>columnNames</code> is  mapped to column 0 in <code>newData</code>. Each row in  <code>newData</code>  is adjusted to match the number of columns in <code>columnNames</code>  either by truncating the <code>Vector</code> if it is too long,  or adding <code>null</code> values if it is too short.  <p><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newData</CODE> - the new data vector<DD><CODE>columnNames</CODE> - the names of the columns<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#newDataAvailable(javax.swing.event.TableModelEvent)"><CODE>newDataAvailable(javax.swing.event.TableModelEvent)</CODE></A>, <A HREF="../../../javax/swing/table/DefaultTableModel.html#getDataVector()"><CODE>getDataVector()</CODE></A></DL></DD></DL><HR><A NAME="setDataVector(java.lang.Object[][], java.lang.Object[])"><!-- --></A><H3>setDataVector</H3><PRE>public void <B>setDataVector</B>(<A HREF="../../../java/lang/Object.html">Object</A>[][]&nbsp;newData,                          <A HREF="../../../java/lang/Object.html">Object</A>[]&nbsp;columnNames)</PRE><DL><DD>Replaces the value in the <code>dataVector</code> instance   variable with the values in the array <code>newData</code>.  The first index in the <code>Object[][]</code>  array is the row index and the second is the column index.  <code>columnNames</code> are the names of the new columns.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newData</CODE> - the new data vector<DD><CODE>columnNames</CODE> - the names of the columns<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#setDataVector(java.util.Vector, java.util.Vector)"><CODE>setDataVector(Vector, Vector)</CODE></A></DL></DD></DL><HR><A NAME="newDataAvailable(javax.swing.event.TableModelEvent)"><!-- --></A><H3>newDataAvailable</H3><PRE>public void <B>newDataAvailable</B>(<A HREF="../../../javax/swing/event/TableModelEvent.html">TableModelEvent</A>&nbsp;event)</PRE><DL><DD>Equivalent to <code>fireTableChanged</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>event</CODE> - the change event</DL></DD></DL><HR><A NAME="newRowsAdded(javax.swing.event.TableModelEvent)"><!-- --></A><H3>newRowsAdded</H3><PRE>public void <B>newRowsAdded</B>(<A HREF="../../../javax/swing/event/TableModelEvent.html">TableModelEvent</A>&nbsp;event)</PRE><DL><DD>Ensures that the new rows have the correct number of columns.  This is accomplished by  using the <code>setSize</code> method in  <code>Vector</code> which truncates vectors  which are too long, and appends <code>null</code>s if they  are too short.  This method also sends out a <code>tableChanged</code>  notification message to all the listeners.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>event</CODE> - this <code>TableModelEvent</code> describes                            where the rows were added. 				 If <code>null</code> it assumes                           all the rows were newly added<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#getDataVector()"><CODE>getDataVector()</CODE></A></DL></DD></DL><HR><A NAME="rowsRemoved(javax.swing.event.TableModelEvent)"><!-- --></A><H3>rowsRemoved</H3><PRE>public void <B>rowsRemoved</B>(<A HREF="../../../javax/swing/event/TableModelEvent.html">TableModelEvent</A>&nbsp;event)</PRE><DL><DD>Equivalent to <code>fireTableChanged</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>event</CODE> - the change event</DL></DD></DL><HR><A NAME="setColumnIdentifiers(java.util.Vector)"><!-- --></A><H3>setColumnIdentifiers</H3><PRE>public void <B>setColumnIdentifiers</B>(<A HREF="../../../java/util/Vector.html">Vector</A>&nbsp;newIdentifiers)</PRE><DL><DD>Replaces the column identifiers in the model.  If the number of <code>newIdentifier</code>s is greater than the current number of columns, new columns are added to the end of each row in the model. If the number of <code>newIdentifier</code>s is less than the current number of columns, all the extra columns at the end of a row are discarded. <p><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newIdentifiers</CODE> - vector of column identifiers.  If				<code>null</code>, set the model                          to zero columns<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#setNumRows(int)"><CODE>setNumRows(int)</CODE></A></DL></DD></DL><HR><A NAME="setColumnIdentifiers(java.lang.Object[])"><!-- --></A><H3>setColumnIdentifiers</H3><PRE>public void <B>setColumnIdentifiers</B>(<A HREF="../../../java/lang/Object.html">Object</A>[]&nbsp;newIdentifiers)</PRE><DL><DD>Replaces the column identifiers in the model.  If the number of <code>newIdentifier</code>s is greater than the current number of columns, new columns are added to the end of each row in the model. If the number of <code>newIdentifier</code>s is less than the current number of columns, all the extra columns at the end of a row are discarded. <p><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>newIdentifiers</CODE> - array of column identifiers. 				If <code>null</code>, set                          the model to zero columns<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#setNumRows(int)"><CODE>setNumRows(int)</CODE></A></DL></DD></DL><HR><A NAME="setNumRows(int)"><!-- --></A><H3>setNumRows</H3><PRE>public void <B>setNumRows</B>(int&nbsp;newSize)</PRE><DL><DD>Obsolete as of Java 2 platform v1.3.  Please use <code>setRowCount</code> instead.<DD><DL></DL></DD></DL><HR><A NAME="setRowCount(int)"><!-- --></A><H3>setRowCount</H3><PRE>public void <B>setRowCount</B>(int&nbsp;rowCount)</PRE><DL><DD>Sets the number of rows in the model.  If the new size is greater  than the current size, new rows are added to the end of the model  If the new size is less than the current size, all  rows at index <code>rowCount</code> and greater are discarded. <p><DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#setColumnCount(int)"><CODE>setColumnCount(int)</CODE></A></DL></DD></DL><HR><A NAME="setColumnCount(int)"><!-- --></A><H3>setColumnCount</H3><PRE>public void <B>setColumnCount</B>(int&nbsp;columnCount)</PRE><DL><DD>Sets the number of columns in the model.  If the new size is greater  than the current size, new columns are added to the end of the model   with <code>null</code> cell values.  If the new size is less than the current size, all columns at index  <code>columnCount</code> and greater are discarded.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>columnCount</CODE> - the new number of columns in the model<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#setColumnCount(int)"><CODE>setColumnCount(int)</CODE></A></DL></DD></DL><HR><A NAME="addColumn(java.lang.Object)"><!-- --></A><H3>addColumn</H3><PRE>public void <B>addColumn</B>(<A HREF="../../../java/lang/Object.html">Object</A>&nbsp;columnName)</PRE><DL><DD>Adds a column to the model.  The new column will have the  identifier <code>columnName</code>.  This method will send a  <code>tableChanged</code> notification message to all the listeners.  This method is a cover for <code>addColumn(Object, Vector)</code> which  uses <code>null</code> as the data vector.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>columnName</CODE> - the identifier of the column being added<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>columnName</code>						is <code>null</code></DL></DD></DL><HR><A NAME="addColumn(java.lang.Object, java.util.Vector)"><!-- --></A><H3>addColumn</H3><PRE>public void <B>addColumn</B>(<A HREF="../../../java/lang/Object.html">Object</A>&nbsp;columnName,                      <A HREF="../../../java/util/Vector.html">Vector</A>&nbsp;columnData)</PRE><DL><DD>Adds a column to the model.  The new column will have the  identifier <code>columnName</code>.  <code>columnData</code> is the  optional vector of data for the column.  If it is <code>null</code>  the column is filled with <code>null</code> values.  Otherwise,  the new data will be added to model starting with the first  element going to row 0, etc.  This method will send a  <code>tableChanged</code> notification message to all the listeners.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>columnName</CODE> - the identifier of the column being added<DD><CODE>columnData</CODE> - optional data of the column being added<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>columnName</code>						is <code>null</code></DL></DD></DL><HR><A NAME="addColumn(java.lang.Object, java.lang.Object[])"><!-- --></A><H3>addColumn</H3><PRE>public void <B>addColumn</B>(<A HREF="../../../java/lang/Object.html">Object</A>&nbsp;columnName,                      <A HREF="../../../java/lang/Object.html">Object</A>[]&nbsp;columnData)</PRE><DL><DD>Adds a column to the model.  The new column will have the  identifier <code>columnName</code>.  <code>columnData</code> is the  optional array of data for the column.  If it is <code>null</code>  the column is filled with <code>null</code> values.  Otherwise,  the new data will be added to model starting with the first  element going to row 0, etc.  This method will send a  <code>tableChanged</code> notification message to all the listeners.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/swing/table/DefaultTableModel.html#addColumn(java.lang.Object, java.util.Vector)"><CODE>addColumn(Object, Vector)</CODE></A></DL></DD></DL>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?