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

36
LINES

< > BotCompany Repo | #1034215 // AWTOnConceptChangesByClass

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

Libraryless. Click here for Pure Java version (21570L/131K).

1  
sclass AWTOnConceptChangesByClass is AutoCloseable {
2  
  settable JComponent component;
3  
  settable Runnable action;
4  
  settable Concepts concepts;
5  
  settable Class conceptClass;
6  
  settable int firstDelay;
7  
  settable int delay = 500;
8  
  
9  
  volatile long changes = -1, changeCounter;
10  
  javax.swing.Timer timer;
11  
  AutoCloseable closer;
12  
  
13  
  *(Concepts *concepts, Class *conceptClass, JComponent *component, Runnable *action) {}
14  
  
15  
  void install {
16  
    assertNotNull(concepts);
17  
    assertNotNull(conceptClass);
18  
    assertNotNull(component);
19  
    
20  
    bindToComponent(component, ->
21  
      closer = onConceptChangeByClass_notOnAllChanged(concepts, conceptClass, -> ++changeCounter),
22  
      -> { dispose closer; });
23  
      
24  
    timer = installTimer(component, delay, firstDelay, r _trigger);
25  
  }
26  
  
27  
  void _trigger {
28  
    long c = changeCounter;
29  
    if (changes != c) {
30  
      changes = c;
31  
      action?.run();
32  
    }
33  
  }
34  
  
35  
  close { dispose timer; dispose closer; }
36  
}

Author comment

Began life as a copy of #1033869

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034215
Snippet name: AWTOnConceptChangesByClass
Eternal ID of this version: #1034215/8
Text MD5: b0e8ee0b4089a3efa12a01fbeb13585b
Transpilation MD5: 87b86fab3e4ad07aeac97c1d90872f30
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-12 22:28:57
Source code size: 986 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 279
Version history: 7 change(s)
Referenced in: [show references]