How do I create a JTable that that uses the DefaultTableModel?

John Zukowski

Just create the model, then use the table constructor that accepts the model.

For example:

Object rows[][] = {
  {"one",   "ichi - u4E00"},
  {"two",   "ni - u4E8C"},
  {"three", "san - u4E09"},
  {"four",  "shi - u56DB"},
  {"five",  "go - u4E94"},
  {"six",   "roku - u516D"},
  {"seven", "shichi - u4E03"},
  {"eight", "hachi - u516B"},
  {"nine",  "kyu - u4E5D"},
  {"ten",   "ju - u5341"}
Object headers[] = {"English", "Japanese"};
TableModel model = new DefaultTableModel(rows, headers);
JTable table = new JTable (model);
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.