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

73
LINES

< > BotCompany Repo | #1006954 // onChange

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

Libraryless. Click here for Pure Java version (11110L/62K).

static <A extends JSpinner> A onChange(A spinner, O r) {
  ret onChange(spinner, toRunnable(r));
}

static <A extends JSpinner> A onChange(A spinner, Runnable r) {
  if (r != null)
    swing { spinner.addChangeListener(changeListener(r)); }
  ret spinner;
}

static <A extends AbstractButton> A onChange(A b, Runnable r) {
  swing { b.addItemListener(itemListener(r)); }
  ret b;
}

svoid onChange(JTextComponent tc, Runnable r) {
  onUpdate(tc, r);
}

static <A extends JSlider> A onChange(A slider, Runnable r) {
  swing { slider.addChangeListener(changeListener(r)); }
  ret slider;
}

static <A> JComboBox<A> onChange(JComboBox<A> cb, ChangeTriggerable r) {
  ret onChange(cb, new ChangeTrigger(r));
}

static <A> JComboBox<A> onChange(JComboBox<A> cb, Updateable r) {
  ret onChange(cb, new UpdateTrigger(r));
}

static <A> JComboBox<A> onChange(JComboBox<A> cb, IVF1<A> f) {
  if (f != null) addActionListener(cb, -> f.get(getSelectedItem_typed(cb)));
  ret cb;
}

// Note: JComboBox also supports addActionListener.
// Not sure if that would help us any.
static JComboBox onChange(JComboBox cb, Runnable r) {
  if (isEditableComboBox(cb))
    onChange(textFieldFromComboBox(cb), r);
  else
    onSelectedItem(cb, runnableToIVF1(r));
  ret cb;
}

static <A extends JTabbedPane> A onChange(A tabs, Runnable r) {
  swing { tabs.addChangeListener(changeListener(r)); }
  ret tabs;
}

static <A extends JColorChooser> A onChange(Runnable r, A cc) {
  if (cc != null && r != null) swing {
    cc.getSelectionModel().addChangeListener(changeListener(r));
  }
  ret cc;
}

static <A extends IHasChangeListeners> A onChange(A a, ChangeTriggerable b) {
  if (a != null && b != null) a.onChange(new ChangeTrigger(b));
  ret a;
}

static <A extends IHasChangeListeners> A onChange(A a, Updateable b) {
  if (a != null && b != null) a.onChange(new UpdateTrigger(b));
  ret a;
}

static <A extends IHasChangeListeners> A onChange(A a, Runnable r) {
  if (a != null && r != null) a.onChange(r);
  ret a;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006954
Snippet name: onChange
Eternal ID of this version: #1006954/38
Text MD5: 738c31ac4606598a1ee48156ee5c5684
Transpilation MD5: ac978fd6fdd3a0015b4c1588f96e4718
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-05-05 09:01:59
Source code size: 2069 bytes / 73 lines
Pitched / IR pitched: No / No
Views / Downloads: 850 / 1274
Version history: 37 change(s)
Referenced in: [show references]