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

27
LINES

< > BotCompany Repo | #1007300 // updateCanvas - repaint jcanvas

JavaX fragment (include)

static int updateCanvas_retryInterval = 50;

// if makeImg returns null, it is recalled after a delay
static void updateCanvas(final Canvas canvas, fO makeImg) {
  awtIfNecessary {
    if (canvas.updating || canvas.getWidth() == 0) ret;
    canvas.updating = true;
    try {
      BufferedImage img = asBufferedImage(callF(makeImg, canvas.getWidth(), canvas.getHeight()));
      if (img != null) {
        canvas.setImage(img);
        canvas.updating = false;
      } else
        awtLater(updateCanvas_retryInterval, r {
          canvas.updating = false;
          updateCanvas(canvas, makeImg);
        });
    } catch e {
      canvas.updating = false;
      throw rethrow(e);
    }
  }
}

static void updateCanvas(final Canvas canvas) {
  if (canvas != null) canvas.update();
}

Author comment

Began life as a copy of #1007284

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007300
Snippet name: updateCanvas - repaint jcanvas
Eternal ID of this version: #1007300/16
Text MD5: bdca4fb73c2192d9b9ba1418dfb98f1c
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-21 16:52:32
Source code size: 809 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 641 / 672
Version history: 15 change(s)
Referenced in: [show references]