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

24
LINES

< > BotCompany Repo | #1026815 // Battery Tray Icon

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 6315K of libraries. Click here for Pure Java version (4694L/22K).

!7

cmodule BatteryTrayIcon > DynPrintLog {
  transient S value;
  transient JLabel lbl;
  transient bool _startMinimized = true;
  switchable double interval = 10.0; // restart to take effect
  transient double level;
  
  start {
    dm_addTrayIcon(onLeftClick(rThreadEnter dm_showModule,
 lbl = dm_fieldLabel_noAutoToolTip value()));
    doEveryAndNow(interval, r actualUpdate);
    dm_registerAs_direct batteryLevel();
  }
  
  void actualUpdate {
    S value = "-";
    level = oshi_batteryLevel_withZeroPercentFix();
    if (!isNaN(level)) value = iround(level) + "%";
    if (set_trueIfChanged(this, +value))
      fireChangeWithoutPersisting();
    toolTip(lbl, "Battery level: " + value);
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1026815
Snippet name: Battery Tray Icon
Eternal ID of this version: #1026815/4
Text MD5: bbf5e4a831027e7fe2cdebe979a2d68b
Transpilation MD5: c09941bfe3d72aa97e4118b2d5c1e74f
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-25 01:10:50
Source code size: 722 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 248 / 1748
Version history: 3 change(s)
Referenced in: