Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. class MyTableModel extends AbstractTableModel {
  2.     private String[] columnNames = {"Prénom", "Nom", "Couleur favorite", "Homme", "Sport"};
  3.     private Object[][] data = {
  4.                 {"Johnathan", "Sykes", Color.red, true, "TENNIS"},
  5.                 {"Nicolas", "Van de Kampf", Color.black, true, "FOOTBALL"},
  6.                 {"Damien", "Cuthbert", Color.cyan, true, "RIEN"},
  7.                 {"Corinne", "Valance", Color.blue, false, ".NATATION"},
  8.                 {"Emilie", "Schrödinger", Color.magenta, false, ".FOOTBALL"},
  9.                 {"Delphine", "Duke", Color.yellow, false, ".TENNIS"},
  10.                 {"Eric", "Trump", Color.pink, true, ".FOOTBALL"},
  11.         };
  12.  
  13.     public int getColumnCount() {
  14.         return columnNames.length;
  15.     }
  16.  
  17.     public int getRowCount() {
  18.         return data.length;
  19.     }
  20.  
  21.     public String getColumnName(int col) {
  22.         return columnNames[col];
  23.     }
  24.  
  25.     public Object getValueAt(int row, int col) {
  26.         return data[row][col];
  27.     }
  28.  
  29.     public Class getColumnClass(int c) {
  30.         return getValueAt(0, c).getClass();
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement