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

17
LINES

< > BotCompany Repo | #1020315 // addInnerMargin - add inner margin to JComponent on the inside of border (e.g. a JButton)

JavaX fragment (include)

1  
import javax.swing.border.*;
2  
3  
static <A extends JComponent> A addInnerMargin(final int top, final int left, final int bottom, final int right, final A c) {
4  
  if (c != null) swing {
5  
    Border margin = BorderFactory.createEmptyBorder(top, left, bottom, right);
6  
    c.setBorder(jCompoundBorder(margin, c.getBorder()));
7  
  }
8  
  ret c;
9  
}
10  
11  
static <A extends JComponent> A addInnerMargin(int w, A c) {
12  
  ret addInnerMargin(w, w, w, w, c);
13  
}
14  
15  
static <A extends JComponent> A addInnerMargin(int w, int h, A c) {
16  
  ret addInnerMargin(h, w, h, w, c);
17  
}

Author comment

Began life as a copy of #1020072

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020315
Snippet name: addInnerMargin - add inner margin to JComponent on the inside of border (e.g. a JButton)
Eternal ID of this version: #1020315/3
Text MD5: 53d4cee96bed4714bafcc43c80d375e1
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-06 16:36:51
Source code size: 558 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 376
Version history: 2 change(s)
Referenced in: [show references]