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 str(cb.getSelectedItem());
}
endifndef

ifdef Android
svoid getText() {} // dummy
endifdef

Author comment

Began life as a copy of #1006455

download  show line numbers  debug dex   

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

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/18
Text MD5: 4964861a2f92c41453009e725e332a59
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-24 14:03:23
Source code size: 664 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 332 / 356
Version history: 17 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1006642 & http://1006642.tinybrain.de