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

25
LINES

< > BotCompany Repo | #1001661 // Find active component (text field or other, in current VM)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (79L/1K/3K).

!747
!awt {

m {
  p {
    awt {
      Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      if (focused instanceof JTextField)
        print("Focused text field: " + focused);
      else if (focused != null)
        print("Focused other object: " + focused);
      else
        print("No focused object.");
      
      /*
      L<JTextField> l = allSwingComponentsOfType(JTextField.class);
      print(l.size() + " text field(s) found.");
      
      for (JTextField tf : l)
        if (tf.isFocused...()) {
        }
      */
    }
  }
}

Author comment

Began life as a copy of #1001374

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001661
Snippet name: Find active component (text field or other, in current VM)
Eternal ID of this version: #1001661/1
Text MD5: a6f5d426fb7c2713f5e2a1bdac1654c8
Transpilation MD5: 0b253a9ef21aa5d2e25776cc956f0664
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-11-10 20:47:52
Source code size: 608 bytes / 25 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 561 / 601
Referenced in: [show references]