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).

1  
!747
2  
!awt {
3  
4  
m {
5  
  p {
6  
    awt {
7  
      Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
8  
      if (focused instanceof JTextField)
9  
        print("Focused text field: " + focused);
10  
      else if (focused != null)
11  
        print("Focused other object: " + focused);
12  
      else
13  
        print("No focused object.");
14  
      
15  
      /*
16  
      L<JTextField> l = allSwingComponentsOfType(JTextField.class);
17  
      print(l.size() + " text field(s) found.");
18  
      
19  
      for (JTextField tf : l)
20  
        if (tf.isFocused...()) {
21  
        }
22  
      */
23  
    }
24  
  }
25  
}

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: 633 / 697
Referenced in: [show references]