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.

1  
// interval is in seconds
2  
static JLabel lambda0Like jLabelShortCalcedEvery(IF0 calc, double interval) {
3  
  JLabel label = jSimpleLabel();
4  
  if (calc != null) awtEveryAndNow(label, interval, -> {
5  
    pcall {
6  
      O o = calc!;
7  
      S toolTip, text;
8  
      if (o cast WithToolTip) {
9  
        toolTip = o.toolTip();
10  
        text = str(o!);
11  
      } else {
12  
        text = toolTip = str(o);
13  
      }
14  
      setToolTip(label, toolTip);
15  
      label.setText(text);
16  
    }
17  
  });
18  
  ret label;
19  
}
20  
21  
static JLabel lambda0Like jLabelShortCalcedEvery(double interval, IF0 calc) {
22  
  ret jLabelShortCalcedEvery(calc, interval);
23  
}

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: 106 / 201
Version history: 8 change(s)
Referenced in: [show references]