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

41
LINES

< > BotCompany Repo | #1001374 // Add Kilroy to JList (code for injection)

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

Libraryless. Click here for Pure Java version (128L/2K/5K).

!747
!awt {

m {
  p {
    awt {
      L<JFrame> frames = listAllFrames();
      print(frames.size() + " frame(s) found.");
      
      L<JList> l = allSwingComponentsOfType(JList.class);
      print(l.size() + " list(s) found.");
      
      for (JList list : l) {
        if (!list.isShowing()) {
          print("Skipping list, not showing.");
          continue;
        }
        
        ListModel model = list.getModel();
        print("List entries: " + model.getSize());
        
        S myTag = "Kilroy was here! :)";
        
        if (!(model instanceof DefaultListModel)) {
          //print("Cannot modify, not a DefaultListModel (" + model.getClass().getName() + ")");
          convertToDefaultListModel(list);
          model = list.getModel();
        }
          
        if (model.getSize() != 0 && eq(myTag, model.getElementAt(model.getSize()-1)))
          print("Kilroy was here already :)");
        else {
          print("Trying to add a string (yes it may fail if it's not a string list) :)");
          
          DefaultListModel m = cast model;
          m.addElement(myTag);
        }
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001374
Snippet name: Add Kilroy to JList (code for injection)
Eternal ID of this version: #1001374/1
Text MD5: 78302cd745ae10b83583d545ce5880e1
Transpilation MD5: ad21b761ebc15c39a74f950c37fbe8ef
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-11-01 13:39:43
Source code size: 1181 bytes / 41 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 786 / 1077
Referenced in: #1001376 - Injection test (kilroy all VM's JLists)
#1001661 - Find active component (text field or other, in current VM)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)