sclass JNavigation extends JPanel {
JList list;
SingleComponentPanel scp;
Map<S, F0<JComponent>> contentMakers = synchroMap();
S lastItem = "";
bool autoOpenFirstPage = true;
*() {
list = jlist();
scp = singleComponentPanel();
makeFakeSingleComponentPanel(this, jhsplit(list, scp));
onSelectionChangedAndNow(list, voidfunc(S item) {
if (eq(item, lastItem)) ret;
lastItem = item;
JComponent content = pcallF(contentMakers.get(item));
if (content == null) content = jcenteredimage(#1101244);
scp.setComponent(content);
});
}
void addPage(fS name, JComponent content) {
addPage(name, f0_const(content));
}
void addPageOnTop(fS name, final F0<JComponent> makeContent) {
swing {
contentMakers.put(name, makeContent);
insertListItem(list, 0, name);
if (jlistSize(list) == 1) setSelectedIndex(list, 0);
}
}
void addPage(fS name, final F0<JComponent> makeContent) {
swing {
contentMakers.put(name, makeContent);
addListItem(list, name);
if (jlistSize(list) == 1) setSelectedIndex(list, 0);
}
}
}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: | #1015278 |
| Snippet name: | JNavigation |
| Eternal ID of this version: | #1015278/10 |
| Text MD5: | 03292551023581b77f31cdd885f0f154 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-05-13 12:11:21 |
| Source code size: | 1168 bytes / 40 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 831 / 1398 |
| Version history: | 9 change(s) |
| Referenced in: | [show references] |