Home Segments Top Top Previous Next

986: Mainline

To make use of the RatingTableModel class defined in Segment 985, you define a subclass of the JTable class. Note that you define in that subclass a constructor that calls the superclass's constructor that takes a table-model argument. That argument is an instance of the RatingTableModel class defined in Segment 985.

import java.util.*; 
import javax.swing.*; 
import javax.swing.table.*;                            
public class RatingTable extends JTable { 
 public RatingTable (Vector rows, Vector columns) { 
  super(new RatingTableModel(rows, columns)); 
 } 
}