Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2322L/16K).
1 | !7 |
2 | |
3 | abstract sclass AbstractLayoutManager implements LayoutManager { |
4 | Dimension preferredSize = new Dimension(100, 100); |
5 | bool invalidate; |
6 | |
7 | public void addLayoutComponent(String name, Component comp) { |
8 | print("addLayoutComponent called"); |
9 | } |
10 | public void removeLayoutComponent(Component comp) { |
11 | print("removeLayoutComponent called"); |
12 | } |
13 | |
14 | public Dimension preferredLayoutSize(Container parent) { |
15 | print("preferredLayoutSize called (" + invalidate + ")"); |
16 | layoutContainer(parent); |
17 | //validate(parent); |
18 | ret preferredSize; |
19 | } |
20 | |
21 | public Dimension minimumLayoutSize(Container parent) { |
22 | print("minimumLayoutSize called"); |
23 | ret new Dimension(10, 10); |
24 | } |
25 | |
26 | void validate(Container parent) { |
27 | if (invalidate) { |
28 | invalidate = false; |
29 | layoutContainer(parent); |
30 | } |
31 | } |
32 | } |
33 | |
34 | p-substance { |
35 | JPanel panel = new JPanel(new AbstractLayoutManager { |
36 | public void layoutContainer(Container parent) { |
37 | Dimension size = parent.getSize(); |
38 | print("layoutContainer called, size=" + size); |
39 | int y = 10; |
40 | for (Component c : parent.getComponents()) { |
41 | int h = c.getPreferredSize().height; |
42 | c.setBounds(10, y, size.width-20, h); |
43 | y += h + 10; |
44 | } |
45 | preferredSize = componentsBoundingSize(parent, 10); |
46 | } |
47 | }); |
48 | |
49 | for i to 10: |
50 | panel.add(jtextfield()); |
51 | print("components added"); |
52 | |
53 | showFrame(panel); |
54 | } |
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: | 628 / 1201 |
Version history: | 3 change(s) |
Referenced in: | [show references] |