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.

// userChangeListener is called only when user changes selected item
// (not when var is changed)
static <B, A extends JComboBox<B>> A bindComboBoxToVar_withUserChangeListener(A cb, IVarWithNotify<B> var, Runnable userChangeListener) {
  new BoolVar inVarChange;
  if (var != null) {
    bindListenerToComponent(cb, var, -> {
      temp tempSetBoolVar(inVarChange, true);
      selectItem(cb, var!);
    });
    onChange(cb, (Runnable) () -> {
      var.set(getSelected(cb));
      if (!inVarChange!)
        pcallF(userChangeListener);
    });
  }
  ret cb;
}

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: 182 / 251
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)