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)

import javax.swing.border.*;

static <A extends JComponent> A addInnerMargin(final int top, final int left, final int bottom, final int right, final A c) {
  if (c != null) swing {
    Border margin = BorderFactory.createEmptyBorder(top, left, bottom, right);
    c.setBorder(jCompoundBorder(margin, c.getBorder()));
  }
  ret c;
}

static <A extends JComponent> A addInnerMargin(int w, A c) {
  ret addInnerMargin(w, w, w, w, c);
}

static <A extends JComponent> A addInnerMargin(int w, int h, A c) {
  ret addInnerMargin(h, w, h, w, c);
}

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: 271 / 301
Version history: 2 change(s)
Referenced in: [show references]