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

17
LINES

< > BotCompany Repo | #1036087 // VerticalCenterLayout [works only with at most one component]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9229L/51K).

1  
sclass VerticalCenterLayout > AbstractLayoutManager {
2  
  public void layoutContainer(Container parent) {
3  
    L<Component> components = getComponents(parent);
4  
    if (l(components) > 1)
5  
      ret with print("VerticalCenterLayout fail");
6  
    
7  
    Component c = first(components);
8  
    if (c == null) ret;
9  
    
10  
    int w = parent.getWidth(), h = parent.getHeight();
11  
    Dimension size = c.getPreferredSize();
12  
    int y = (h-size.height)/2;
13  
    c.setBounds(0, y, w, size.height);
14  
15  
    preferredSize(size);
16  
  }
17  
}

Author comment

Began life as a copy of #1035946

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036087
Snippet name: VerticalCenterLayout [works only with at most one component]
Eternal ID of this version: #1036087/3
Text MD5: 8df28778f4c48249976cf57dd076a518
Transpilation MD5: 947e5324a36fa51a5aeaa2ecc82c85b1
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-07 05:50:09
Source code size: 521 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 61 / 96
Version history: 2 change(s)
Referenced in: [show references]