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

26
LINES

< > BotCompany Repo | #1006642 // getText - get entered text/selected item from JTextComponent or JComboBox (thread-safe)

JavaX fragment (include)

1  
ifndef Android
2  
static S getText(final AbstractButton c) {
3  
  ret c == null ? "" : (S) swingAndWait(func { c.getText() });
4  
}
5  
6  
static S getText(final JTextComponent c) {
7  
  ret c == null ? "" : (S) swingAndWait(func { c.getText() });
8  
}
9  
10  
static S getText(final JLabel l) {
11  
  ret l == null ? "" : (S) swingAndWait(func { l.getText() });
12  
}
13  
14  
// returns the contents of text field for editable combo box
15  
static S getText(final JComboBox cb) {
16  
  if (cb == null) null;
17  
  if (isEditableComboBox(cb))
18  
    ret unnull((S) cb.getEditor().getItem());
19  
  else
20  
    ret strOrNull(cb.getSelectedItem());
21  
}
22  
endifndef
23  
24  
ifdef Android
25  
svoid getText() {} // dummy
26  
endifdef

Author comment

Began life as a copy of #1006455

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006642
Snippet name: getText - get entered text/selected item from JTextComponent or JComboBox (thread-safe)
Eternal ID of this version: #1006642/19
Text MD5: ffc237186e4f0dd72c6081e7adc50389
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-26 14:17:15
Source code size: 670 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 663 / 730
Version history: 18 change(s)
Referenced in: [show references]