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

13
LINES

< > BotCompany Repo | #1015211 // selectItem - for JComboBox or JList

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

Libraryless. Click here for Pure Java version (2983L/18K).

1  
static <A> JComboBox<A> selectItem(A item, JComboBox<A> cb) {
2  
  if (cb != null) swing { cb.setSelectedItem(item); }
3  
  ret cb;
4  
}
5  
6  
static <A> JComboBox<A> selectItem(JComboBox<A> cb, A item) {
7  
  ret selectItem(item, cb);
8  
}
9  
10  
static <A> JList<A> selectItem(JList<A> list, A item) {
11  
  swing { selectRow(list, jlist_indexOf(list, item)); }
12  
  ret list;
13  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015211
Snippet name: selectItem - for JComboBox or JList
Eternal ID of this version: #1015211/6
Text MD5: 8b3f6e69cb982fb4de9ef2ac138c52a7
Transpilation MD5: 42d4993a6c5e3ddfc839cc762ccdcb36
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-26 15:10:26
Source code size: 359 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 565 / 830
Version history: 5 change(s)
Referenced in: [show references]