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

23
LINES

< > BotCompany Repo | #1034796 // jLabelShortCalcedEvery - JLabel recalculated regularly in Swing thread (keep it snappy)

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (8196L) is out of date.

// interval is in seconds
static JLabel lambda0Like jLabelShortCalcedEvery(IF0 calc, double interval) {
  JLabel label = jSimpleLabel();
  if (calc != null) awtEveryAndNow(label, interval, -> {
    pcall {
      O o = calc!;
      S toolTip, text;
      if (o cast WithToolTip) {
        toolTip = o.toolTip();
        text = str(o!);
      } else {
        text = toolTip = str(o);
      }
      setToolTip(label, toolTip);
      label.setText(text);
    }
  });
  ret label;
}

static JLabel lambda0Like jLabelShortCalcedEvery(double interval, IF0 calc) {
  ret jLabelShortCalcedEvery(calc, interval);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034796
Snippet name: jLabelShortCalcedEvery - JLabel recalculated regularly in Swing thread (keep it snappy)
Eternal ID of this version: #1034796/9
Text MD5: 58a199547adee0b54f1f0aa890cbb529
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-05 19:32:24
Source code size: 627 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 102 / 195
Version history: 8 change(s)
Referenced in: [show references]