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

21
LINES

< > BotCompany Repo | #1007221 // tableSetColumnWidths

JavaX fragment (include)

1  
sbool tableSetColumnWidths_debug;
2  
3  
static void tableSetColumnWidths(final JTable table, final Map<S, Int> widths) {
4  
  swing { pcall {
5  
    TableColumnModel tcm = table.getColumnModel();
6  
    int n = tcm.getColumnCount();
7  
    for i to n: {
8  
      TableColumn tc = tcm.getColumn(i);
9  
      Int w = widths.get(str(tc.getHeaderValue());
10  
      if (w != null) {
11  
        tc.setWidth(w);
12  
        if (tableSetColumnWidths_debug)
13  
          print("Setting width of column " + i + " to " + w);
14  
      }
15  
    }
16  
  }}
17  
}
18  
19  
static void tableSetColumnWidths(JTable table, O... widths) {
20  
  tableSetColumnWidths(table, litorderedmap(widths));
21  
}

Author comment

Began life as a copy of #1007220

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: #1007221
Snippet name: tableSetColumnWidths
Eternal ID of this version: #1007221/13
Text MD5: 0a020f33162b4505707a2ade479259e3
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-23 21:01:13
Source code size: 639 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 505 / 479
Version history: 12 change(s)
Referenced in: [show references]