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

13
LINES

< > BotCompany Repo | #1014537 // paintCenteredBackgroundImage

JavaX fragment (include)

static void paintCenteredBackgroundImage(Component c, Graphics g, BufferedImage image) {
  paintCenteredBackgroundImage(c, g, image, c.getBackground());
}

static void paintCenteredBackgroundImage(Component c, Graphics g, BufferedImage image, Color backgroundColor) {
  int w = c.getWidth();  
  int h = c.getHeight();
  g.setColor(backgroundColor);
  g.fillRect(0, 0, w, h);
  if (image == null) ret;
  int iw = image.getWidth(), ih = image.getHeight();
  g.drawImage(image, (w-iw)/2, (h-ih)/2, c);
}

Author comment

Began life as a copy of #1009941

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014537
Snippet name: paintCenteredBackgroundImage
Eternal ID of this version: #1014537/5
Text MD5: bc9a929492d3bd9cd08837cee93e464d
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-11 13:27:12
Source code size: 513 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 294 / 331
Version history: 4 change(s)
Referenced in: [show references]