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

29
LINES

< > BotCompany Repo | #1005319 - SingleComponentPanel

JavaX fragment (include)

1  
sclass SingleComponentPanel extends JPanel {
2  
  *() { super(new BorderLayout); }
3  
4  
  *(Component component) {
5  
    this();
6  
    if (component != null) setComponent(component);
7  
  }
8  
9  
  void setComponent(final Component component) {
10  
    swing {
11  
      removeAll();
12  
      if (component != null)
13  
        add(BorderLayout.CENTER, wrap(component));
14  
      _revalidate(SingleComponentPanel.this);
15  
    }
16  
  }
17  
  
18  
  // Sometimes we need this?
19  
  void setComponentAndRevalidateParent(Component component) {
20  
    setComponent(component);
21  
    _revalidate(_getParent(this));
22  
  }
23  
  
24  
  void noComponent() { setComponent(null); }
25  
  
26  
  Component getComponent() {
27  
    ret getComponentCount() == 0 ? null : getComponent(0);
28  
  }
29  
}

download  show line numbers  debug dex   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, sawdedvomwva, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1005319
Snippet name: SingleComponentPanel
Eternal ID of this version: #1005319/13
Text MD5: 73b375db2eeffed6170f0051eaa1bbc7
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-01 01:35:15
Source code size: 727 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 417 / 2896
Version history: 12 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1005319 & http://1005319.tinybrain.de