Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1004995 // fillTableWithData (strings, images, bools) - now makes table uneditable

JavaX fragment (include)

static void fillTableWithData(final JTable table, L<L> rows, L<S> colNames) {
  fillTableWithData(table, rows, toStringArray(colNames));
}

// thread-safe
static void fillTableWithData(final JTable table, L<L> rows, S... colNames) {
  final DefaultTableModel model = fillTableWithData_makeModel(rows, colNames);
  
  // TODO: keep model if columns identical?
  setTableModel(table, model);
}

static DefaultTableModel fillTableWithData_makeModel(L<L> rows, S... colNames) {
  Pair<Object[][], O[]> p = fillTableWithData_makeData(rows, colNames);
  ret new DefaultTableModel(p.a, p.b) {
    public Class getColumnClass(int column) {
      return or(_getClass(getValueAt(0, column)), S.class);
    }
    
    public bool isCellEditable(int rowIndex, int columnIndex) {
      ret false;
    }
  };
}

Author comment

Began life as a copy of #1001438

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004995
Snippet name: fillTableWithData (strings, images, bools) - now makes table uneditable
Eternal ID of this version: #1004995/10
Text MD5: 57ea3413414432b12254a68a49cf9750
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-07 00:14:13
Source code size: 821 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 562 / 567
Version history: 9 change(s)
Referenced in: [show references]