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

18
LINES

< > BotCompany Repo | #1004327 // selectRow - select row in a JTable or JList

JavaX fragment (include)

1  
static void selectRow(final JTable table, final int i) {
2  
  if (table != null) swing {
3  
    if (i >= 0 && i < table.getRowCount()) {
4  
      table.setRowSelectionInterval(i, i);
5  
      scrollRowToVisible(table, i);
6  
    } else
7  
      table.clearSelection();
8  
  }
9  
}
10  
11  
static void selectRow(final JList list, final int i) {
12  
  if (list != null) swing {
13  
    if (i >= 0 && i < listRowCount(list))
14  
      list.setSelectedIndex(i);
15  
    else
16  
      list.clearSelection();
17  
  }
18  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004327
Snippet name: selectRow - select row in a JTable or JList
Eternal ID of this version: #1004327/6
Text MD5: 01b9eafc1549db4356a1d2b34b6ef0a7
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-31 16:49:30
Source code size: 475 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 611 / 639
Version history: 5 change(s)
Referenced in: [show references]