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 (5863L/32K).

static <B, A extends JComboBox<B>> A bindComboBoxToVar(IVarWithNotify<B> var, A cb) {
  if (var != null) {
    bindListenerToComponent(cb, var, -> selectItem(cb, var!));
    onChange(cb, -> 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/6
Text MD5: 78f3cab20ee2df39cf23f0d6a56ed175
Transpilation MD5: eede74f2b7876a364dd12004878277ea
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-28 22:24:16
Source code size: 360 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 45 / 93
Version history: 5 change(s)
Referenced in: [show references]