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

26
LINES

< > BotCompany Repo | #1007280 // Test Adapting ImageSurface To Window Size [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Click here for Pure Java version (5921L/42K/149K).

!7

static int delay = 500;

p-substance {
  final new ImageSurface is;
  // is.noMinimumSize = true; // now default
  showFrame(is); // no scroll pane

  print(is.getSize()); // should already be the window's inner size
  
  onResizeAndNow(is, r {
    print("component resized. " + is.getSize());
    awtLater(is, delay, r {
      BufferedImage img = is.getImage();
      if (img.getWidth() != is.getWidth() || img.getHeight() != is.getHeight())
        is.setImage(makeImage(is.getWidth(), is.getHeight()));
    });
  });
}

static BufferedImage makeImage(final int w, final int h) {
  ret renderImage(w, h, func(int x, int y) {
    ret x < w/2 != y < h/2;
  });
}

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: #1007280
Snippet name: Test Adapting ImageSurface To Window Size [WORKS]
Eternal ID of this version: #1007280/12
Text MD5: 45cc3966708f1fe09758d1a26569ecb3
Transpilation MD5: dc855cb229c17694a76c366964fdb574
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-14 22:30:58
Source code size: 691 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 381 / 479
Version history: 11 change(s)
Referenced in: [show references]