Home Segments Top Top Previous Next

1010: Mainline

If you wish to allow selective cell editing, you must change the table model's call to the isCellEditable method. For example, the following allows editing of all the columns, except those devoted to the title and rating.

import java.util.*;
import javax.swing.table.*;
public class RatingTableModel extends DefaultTableModel {
 public RatingTableModel (Vector rows, Vector columns) {
  super(rows, columns);
 }
 public boolean isCellEditable(int row, int column) {
  if (column >= 2) {return true;}       
  return false;                         
 } 
 public Class getColumnClass(int column) { 
  return getValueAt(0, column).getClass(); 
 } 
}