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

17
LINES

< > BotCompany Repo | #1034992 // bindComboBoxToVar_withUserChangeListener

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

Transpiled version (5912L) is out of date.

1  
// userChangeListener is called only when user changes selected item
2  
// (not when var is changed)
3  
static <B, A extends JComboBox<B>> A bindComboBoxToVar_withUserChangeListener(A cb, IVarWithNotify<B> var, Runnable userChangeListener) {
4  
  new BoolVar inVarChange;
5  
  if (var != null) {
6  
    bindListenerToComponent(cb, var, -> {
7  
      temp tempSetBoolVar(inVarChange, true);
8  
      selectItem(cb, var!);
9  
    });
10  
    onChange(cb, (Runnable) () -> {
11  
      var.set(getSelected(cb));
12  
      if (!inVarChange!)
13  
        pcallF(userChangeListener);
14  
    });
15  
  }
16  
  ret cb;
17  
}

Author comment

Began life as a copy of #1034489

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034992
Snippet name: bindComboBoxToVar_withUserChangeListener
Eternal ID of this version: #1034992/8
Text MD5: 5bee596aa116dda5c252ea53f6e26cc0
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-05-13 02:17:09
Source code size: 576 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 105 / 149
Version history: 7 change(s)
Referenced in: [show references]