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)

ifndef Android
static S getText(final AbstractButton c) {
  ret c == null ? "" : (S) swingAndWait(func { c.getText() });
}

static S getText(final JTextComponent c) {
  ret c == null ? "" : (S) swingAndWait(func { c.getText() });
}

static S getText(final JLabel l) {
  ret l == null ? "" : (S) swingAndWait(func { l.getText() });
}

// returns the contents of text field for editable combo box
static S getText(final JComboBox cb) {
  if (cb == null) null;
  if (isEditableComboBox(cb))
    ret unnull((S) cb.getEditor().getItem());
  else
    ret strOrNull(cb.getSelectedItem());
}
endifndef

ifdef Android
svoid getText() {} // dummy
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: 563 / 621
Version history: 18 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1020314 - getBorder