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

11
LINES

< > BotCompany Repo | #1034489 // bindComboBoxToVar

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

Libraryless. Click here for Pure Java version (11346L/63K).

static <B, A extends JComboBox<B>> A bindComboBoxToVar(IVarWithNotify<B> var, A cb) {
  if (var != null) {
    bindListenerToComponent(cb, var, (Runnable) () -> selectItem(cb, var!));
    onChange(cb, (Runnable) () -> var.set(getSelected(cb));
  }
  ret cb;
}

static <B, A extends JComboBox<B>> A bindComboBoxToVar(A cb, IVarWithNotify<B> var) {
  ret bindComboBoxToVar(var, cb);
}

Author comment

Began life as a copy of #1016619

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034489
Snippet name: bindComboBoxToVar
Eternal ID of this version: #1034489/8
Text MD5: 418d316947ad9403d23f016897084a70
Transpilation MD5: e0eefbf2fe7a132fabe0d75acecd6dfb
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:43
Source code size: 392 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 145 / 243
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1034992 - bindComboBoxToVar_withUserChangeListener