Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1008603 // Custom layout manager, adapt to window size [shortened]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2306L/16K).

1  
!7
2  
3  
p-substance {
4  
  JPanel panel = new JPanel(new AbstractLayoutManager {
5  
    public void layoutContainer(Container parent) {
6  
      Dimension size = parent.getSize();
7  
      int y = 10;
8  
      for (Component c : parent.getComponents()) {
9  
        int h = c.getPreferredSize().height;
10  
        c.setBounds(10, y, size.width-20, h);
11  
        y += h + 10;
12  
      }
13  
      preferredSize = componentsBoundingSize(parent, 10);
14  
    }
15  
  });
16  
  
17  
  for i to 10:
18  
    panel.add(jtextfield());
19  
  print("components added");
20  
    
21  
  showFrame(panel);
22  
}

Author comment

Began life as a copy of #1008601

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: #1008603
Snippet name: Custom layout manager, adapt to window size [shortened]
Eternal ID of this version: #1008603/1
Text MD5: ac56e25a20522668d803c81a36beb0c2
Transpilation MD5: b364879a600d2b0d7ee91bb8e9cc88d6
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:31:48
Source code size: 549 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 427 / 886
Referenced in: [show references]