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

27
LINES

< > BotCompany Repo | #1004385 - tableWithSearcher - add search bar on top of JTable

JavaX fragment (include)

static JComponent tableWithSearcher(final JTable t, O... _) {
  final new JTextField input;
  onUpdate(input, new Runnable {
    L lastFiltered, lastOriginal;
    
    public void run() {
      S pat = trim(input.getText());
      
      L<Map<S, O>> data = rawTableData(t);
      if (eq(lastFiltered, data))
        data = lastOriginal;
      
      print("Searching " + n(l(data), "entry"));
      new L data2;
      for (Map<S, O> map : data)
        if (anyValueContainsIgnoreCase(map, pat))
          data2.add(map);
          
      print("Found " + n(l(data2), "entry"));
      lastFiltered = data2;
      lastOriginal = data;
      dataToTable(t, data2);
    }
  });
  JComponent top = withLabel("Search:", input);
  ret boolOptPar(_, 'withMargin) ? northAndCenterWithMargin(top, t) : northAndCenter(top, t);
}

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1004385
Snippet name: tableWithSearcher - add search bar on top of JTable
Eternal ID of this version: #1004385/7
Text MD5: 5e1f986a5114857ddb3042847f3c1f0d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-09 15:23:00
Source code size: 844 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 382 / 350
Version history: 6 change(s)
Referenced in: [show references]

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