Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2322L/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) { Dimension size = parent.getSize(); print("layoutContainer called, size=" + size); int y = 10; for (Component c : parent.getComponents()) { int h = c.getPreferredSize().height; c.setBounds(10, y, size.width-20, h); y += h + 10; } preferredSize = componentsBoundingSize(parent, 10); } }); for i to 10: panel.add(jtextfield()); print("components added"); showFrame(panel); }
Began life as a copy of #1008596
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: | #1008601 |
Snippet name: | Custom layout manager, adapt to window size [WORKS] |
Eternal ID of this version: | #1008601/4 |
Text MD5: | db02de9619edc722f149a91b8e9b8dc2 |
Transpilation MD5: | 3bceb2bc73020250e83e223cfff3586e |
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:28:37 |
Source code size: | 1450 bytes / 54 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 626 / 1198 |
Version history: | 3 change(s) |
Referenced in: | [show references] |