Transpiled version (12335L) is out of date.
// Not buggy anymore? // Note: There seems to be some extra space below the tabs // when using JTattoo. FlatLAF works fine. // TODO: changing tabs at runtime, event handling etc. // Need latest chain: // need latest JExtendedTabbedPane jExtendedTabs setTab setTabTitle onTabSelectedAndNow addTab selectTab countTabs indexOfSelectedTab tabCount selectedTabIndex. sclass JExtendedTabbedPane is Swingable { JTabbedPane tabs; new L<Component> components; SingleComponentPanel scpBesideTabs = scp(); SingleComponentPanel scpPage = scp(); settable bool verbose; *(JTabbedPane _tabs) swing { tabs = _tabs != null ? _tabs : jtabs(); int n = tabCount(tabs); for i to n: { var c = tabs.getComponentAt(i); c.setVisible(true); components.add(c); tabs.setComponentAt(i, emptyPage()); } onTabSelectedAndNow(tabs, l0 updatePage); } void updatePage { int idx = getSelectedIndex(); var c = get(components, idx); if (verbose) printVars("JExtendedTabbedPane.updateTabs", +idx, +c); scpPage.set(c); } // Something with minimum size 0 Component emptyPage() { ret verticalStrut(0); } cachedVisual vertical() ? westAndCenter(centerAndSouthWithMargin(tabs, scpBesideTabs), wrapPage(scpPage)) : northAndCenter(centerAndEastWithMargin(tabs, scpBesideTabs), wrapPage(scpPage)); swappable JComponent wrapPage(JComponent page) { ret page; } selfType setComponentBesideTabs aka setComponentBelowTabs(Component c) { scpBesideTabs.set(c); this; } int getSelectedIndex() { ret tabs.getSelectedIndex(); } void setComponentAt(int i, Component c) { components.set(i, c); if (getSelectedIndex() == i) updatePage(); } Component getComponentAt(int i) { ret components.get(i); } Component getTabComponentAt(int i) { ret tabs.getTabComponentAt(i); } void add(S title, Component c) { components.add(c); tabs.add(title, emptyPage()); } int getTabCount() { ret tabs.getTabCount(); } void setTitleAt(int i, S title) { tabs.setTitleAt(i, title); } void setSelectedIndex(int i) { tabs.setSelectedIndex(i); } bool vertical() { ret tabs.getTabPlacement() == JTabbedPane.LEFT; } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035165 |
Snippet name: | JExtendedTabbedPane - JTabbedPane where you can place a component in the free space beside the tabs |
Eternal ID of this version: | #1035165/34 |
Text MD5: | af6f6cc7337119548daedbc1fc48ae9c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-01-31 21:41:54 |
Source code size: | 2354 bytes / 86 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 236 / 424 |
Version history: | 33 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |