Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2329L/16K).
!7 abstract sclass AbstractLayoutManager implements LayoutManager { Dimension preferredSize = new Dimension(100, 100); bool invalidate; public void addLayoutComponent(String name, Component comp) { print("addLayoutComponent called"); } public void removeLayoutComponent(Component comp) { print("removeLayoutComponent called"); } public Dimension preferredLayoutSize(Container parent) { print("preferredLayoutSize called (" + invalidate + ")"); layoutContainer(parent); //validate(parent); ret preferredSize; } public Dimension minimumLayoutSize(Container parent) { print("minimumLayoutSize called"); ret new Dimension(10, 10); } void validate(Container parent) { if (invalidate) { invalidate = false; layoutContainer(parent); } } } p-substance { JPanel panel = new JPanel(new AbstractLayoutManager { public void layoutContainer(Container parent) { print("layoutContainer called"); int y = 10; for (Component c : parent.getComponents()) { int h = c.getPreferredSize().height; c.setBounds(10, y, 300, h); y += h + 10; } preferredSize = componentsBoundingSize(parent, 10); } }); for i to 10: panel.add(jtextfield()); print("components added"); showFrame(jscroll_centered(panel)); }
Began life as a copy of #1008593
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: | #1008596 |
Snippet name: | Custom layout manager, scrollable [WORKS] |
Eternal ID of this version: | #1008596/11 |
Text MD5: | 35787cfa2c95322a8a8cde19ce8f3e13 |
Transpilation MD5: | 03a1fe6123058aafec096f73bf064d94 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-25 14:21:40 |
Source code size: | 1402 bytes / 53 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 756 / 1264 |
Version history: | 10 change(s) |
Referenced in: | #1008601 - Custom layout manager, adapt to window size [WORKS] |