Libraryless. Click here for Pure Java version (9218L/51K).
// also works when using centering of the component, // e.g. through jscroll_center_borderless svoid onEnclosingScrollPaneResize(JComponent c, Runnable r) { new OnEnclosingScrollPaneResize(c, r).install(); } srecord noeq OnEnclosingScrollPaneResize(JComponent c, Runnable r) { settable bool debug; ComponentAdapter listener; JViewport viewport; void install { if (r == null) ret; bindToComponent(c, -> { viewport = optCast JViewport(getParent(getParent(c))); if (viewport != null) { listener = new ComponentAdapter { public void componentResized(ComponentEvent e) { if (debug) print("Viewport resized"); pcallF(r); } }; viewport.addComponentListener(listener); if (debug) print("OnEnclosingScrollPaneResize installed"); } }, -> { if (listener != null && viewport != null) { viewport.removeComponentListener(listener); if (debug) print("OnEnclosingScrollPaneResize removed"); } }); } }
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035775 |
Snippet name: | onEnclosingScrollPaneResize |
Eternal ID of this version: | #1035775/9 |
Text MD5: | 48b82767f32d21051b724de869c139b0 |
Transpilation MD5: | 57a6e6d73d7c154f3cb3354e584ef2f9 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-23 22:47:04 |
Source code size: | 1074 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 191 / 307 |
Version history: | 8 change(s) |
Referenced in: | [show references] |