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

22
LINES

< > BotCompany Repo | #1007476 // tableSetColumnPreferredWidths

JavaX fragment (include)

sbool tableSetColumnPreferredWidths_debug;

static void tableSetColumnPreferredWidths(final JTable table, final Map<S, Int> widths) {
  if (table == null || widths == null) ret;
  swing { pcall {
    TableColumnModel tcm = table.getColumnModel();
    int n = tcm.getColumnCount();
    for i to n: {
      TableColumn tc = tcm.getColumn(i);
      Int w = widths.get(str(tc.getHeaderValue());
      if (w != null) {
        tc.setPreferredWidth(w);
        if (tableSetColumnPreferredWidths_debug)
          print("Setting preferred width of column " + i + " to " + w);
      }
    }
  }}
}

static void tableSetColumnPreferredWidths(JTable table, O... widths) {
  tableSetColumnPreferredWidths(table, litorderedmap(widths));
}

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: 576 / 582
Version history: 2 change(s)
Referenced in: [show references]