1 | static void fillTableWithStrings(final JTable table, L<L<S>> rows, L<S> colNames) {
|
2 | fillTableWithStrings(table, rows, toStringArray(colNames)); |
3 | } |
4 | |
5 | // thread-safe |
6 | static void fillTableWithStrings(final JTable table, L<L<S>> rows, S... colNames) {
|
7 | final DefaultTableModel model = fillTableWithStrings_makeModel(rows, colNames); |
8 | |
9 | awtIfNecessary {
|
10 | setTableModel(table, model); |
11 | } |
12 | } |
13 | |
14 | static DefaultTableModel fillTableWithStrings_makeModel(L<L<S>> rows, S... colNames) {
|
15 | Object[][] data = new Object[rows.size()][]; |
16 | int w = 0; |
17 | for (int i = 0; i < rows.size(); i++) {
|
18 | L<S> l = rows.get(i); |
19 | Object[] r = new Object[l.size()]; |
20 | for (int j = 0; j < l.size(); j++) |
21 | r[j] = l.get(j); |
22 | data[i] = r; |
23 | w = Math.max(w, l.size()); |
24 | } |
25 | O[] columnNames = new O[w]; |
26 | for (int i = 0; i < w; i++) |
27 | columnNames[i] = i < l(colNames) ? colNames[i] : "?"; |
28 | ret new DefaultTableModel(data, columnNames); |
29 | } |
Began life as a copy of #1001431
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001438 |
| Snippet name: | fillTableWithStrings |
| Eternal ID of this version: | #1001438/1 |
| Text MD5: | 01711fb2ac828e8a0eab5c01a9df8a60 |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-07-29 18:19:15 |
| Source code size: | 957 bytes / 29 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1075 / 1480 |
| Referenced in: | [show references] |