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

16
LINES

< > BotCompany Repo | #1023004 // jTextPane_shrinkTextSizeToFillParentHeight

JavaX fragment (include)

svoid jTextPane_shrinkTextSizeToFillParentHeight(JTextPane pane, O... _) {
  if (pane == null || getParent(pane) == null) ret with callF(optPar onDone(_));
  swing {
    int pref = preferredHeight(pane);
    int h = getParentHeight(pane);
    double ratio = doubleRatio(h, pref);
    if (ratio >= 1) ret with callF(optPar onDone(_));
    float size = pane.getFont().getSize2D();
    float newSize = size-1;
    if (boolPar debug(_)) print("pref=" + pref + ", h=" + h + ", new font size: " + newSize);
    setFontSize(pane, newSize);
    awtLater(optPar delay(_, 50), r {
      jTextPane_shrinkTextSizeToFillParentHeight(pane, _);
    });
  }
}

Author comment

Began life as a copy of #1023001

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023004
Snippet name: jTextPane_shrinkTextSizeToFillParentHeight
Eternal ID of this version: #1023004/7
Text MD5: eeea52f8e79fafeeec1a5907bdee6481
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-20 00:58:34
Source code size: 658 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 244 / 306
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)