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

23
LINES

< > BotCompany Repo | #1005544 // bindTimerToComponent

JavaX fragment (include)

1  
import javax.swing.Timer;
2  
3  
static void bindTimerToComponent(final Timer timer, JFrame f) {
4  
  bindTimerToComponent(timer, f.getRootPane());
5  
}
6  
7  
static void bindTimerToComponent(final Timer timer, JComponent c) {
8  
  if (c.isShowing())
9  
    timer.start();
10  
  
11  
  c.addAncestorListener(new AncestorListener {
12  
    public void ancestorAdded(AncestorEvent event) {
13  
      timer.start();
14  
    }
15  
16  
    public void ancestorRemoved(AncestorEvent event) {
17  
      timer.stop();
18  
    }
19  
20  
    public void ancestorMoved(AncestorEvent event) {
21  
    }
22  
  });
23  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005544
Snippet name: bindTimerToComponent
Eternal ID of this version: #1005544/1
Text MD5: f7f47168ccedbefda77c5765d1c138ed
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-26 15:29:25
Source code size: 551 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 605 / 615
Referenced in: [show references]