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).

!7

p-substance {
  JPanel panel = new JPanel(new AbstractLayoutManager {
    public void layoutContainer(Container parent) {
      Dimension size = parent.getSize();
      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);
}

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: 532 / 1136
Referenced in: #1008605 - Custom layout manager, adapt to window size [shortened 2]