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

22
LINES

< > BotCompany Repo | #1007476 // tableSetColumnPreferredWidths

JavaX fragment (include)

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

Author comment

Began life as a copy of #1007221

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: #1007476
Snippet name: tableSetColumnPreferredWidths
Eternal ID of this version: #1007476/3
Text MD5: 29b58ada34763c53aac593c169c4cc62
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-30 14:02:53
Source code size: 748 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 503 / 510
Version history: 2 change(s)
Referenced in: [show references]