1 | static void autoTableWidth(JTable table) {
|
2 | final TableColumnModel columnModel = table.getColumnModel(); |
3 | for (int column = 0; column < table.getColumnCount(); column++) pcall {
|
4 | int width = 50; // Min width |
5 | for (int row = 0; row < table.getRowCount(); row++) {
|
6 | TableCellRenderer renderer = table.getCellRenderer(row, column); |
7 | Component comp = table.prepareRenderer(renderer, row, column); |
8 | width = Math.max(comp.getPreferredSize().width +1 , width); |
9 | } |
10 | columnModel.getColumn(column).setPreferredWidth(width); |
11 | } |
12 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003891 |
| Snippet name: | autoTableWidth - some attempt at formatting table columns decently |
| Eternal ID of this version: | #1003891/1 |
| Text MD5: | 067b7c415dbd488624866b6b2490398c |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-07-29 18:05:05 |
| Source code size: | 581 bytes / 12 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 825 / 814 |
| Referenced in: | [show references] |