Libraryless. Click here for Pure Java version (9473L/52K).
// Don't call add/remove directly - use addComponent/removeComponent static abstract class DynamicStack extends JPanel { settable int spacing = 10; bool useFiller; *() { this(true); } *(bool useFiller) { super(new GridBagLayout); this.useFiller = useFiller; _addFiller(); } abstract GridBagConstraints _componentConstraints(); abstract GridBagConstraints _fillerConstraints(); void _addFiller { if (useFiller) add(jrigid(), _fillerConstraints()); } void addComponent(final Component c) { addComponents(ll(c)); } void addComponents(Cl<? extends Component> l) swing { fOr (Component c : l) if (c.getParent() != this) add(c, _componentConstraints(), getComponentCount()-(useFiller ? 1 : 0)); revalidate(); } void setComponents(Cl<? extends Component> l) { removeAll(); _addFiller(); addComponents(l); } void clearComponents() { setComponents(null); } void removeComponent(Component c) swing { if (c != null) { remove(c); revalidate(); } } int numComponents() { ret countComponents()-1; } L<Component> components() { ret dropLast(main getComponents(this)); } bool isEmpty() { ret numComponents() == 0; } }
Began life as a copy of #1015034
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015164 |
Snippet name: | DynamicStack - base class of DynamicHStack/DynamicVStack |
Eternal ID of this version: | #1015164/15 |
Text MD5: | 1c73c0e7c5e66bbe063601cccd5e96a1 |
Transpilation MD5: | 880f75f3d3762ce5ce70e5c94a6fbd49 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-10-26 16:41:50 |
Source code size: | 1312 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 476 / 1138 |
Version history: | 14 change(s) |
Referenced in: | [show references] |