![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e910. Removing a Row from a JTable ComponentTo remove a row of data from aJTable component, you need to remove it
from its table model. A simple implementation of a table model that
supports the removal of row data is DefaultTableModel .
When removing a row using DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); // Create some data model.addColumn("Col1"); model.addRow(new Object[]{"r1"}); model.addRow(new Object[]{"r2"}); model.addRow(new Object[]{"r3"}); // Remove the first row model.removeRow(0); // Remove the last row model.removeRow(model.getRowCount()-1);
e908. Appending a Row to a JTable Component e909. Inserting a Row in a JTable Component e911. Moving a Row in a JTable Component e912. Copying a Row or Column in a JTable Component e913. Setting the Height of a Row in a JTable Component e914. Shading Rows and Columns in a JTable Component
© 2002 Addison-Wesley. |