1 | static void scrollRowToVisible(JTable t, int rowIndex) {
|
2 | int colIndex = 0; |
3 | if (!(t.getParent() instanceof JViewport)) |
4 | return; |
5 | |
6 | JViewport viewport = (JViewport) t.getParent(); |
7 | Rectangle rect = t.getCellRect(rowIndex, colIndex, true); |
8 | Rectangle viewRect = viewport.getViewRect(); |
9 | |
10 | int x = viewRect.x; |
11 | int y = viewRect.y; |
12 | |
13 | if (rect.x >= viewRect.x && rect.x <= (viewRect.x + viewRect.width - rect.width)){
|
14 | |
15 | } else if (rect.x < viewRect.x){
|
16 | x = rect.x; |
17 | } else if (rect.x > (viewRect.x + viewRect.width - rect.width)) {
|
18 | x = rect.x - viewRect.width + rect.width; |
19 | } |
20 | |
21 | if (rect.y >= viewRect.y && rect.y <= (viewRect.y + viewRect.height - rect.height)){
|
22 | |
23 | } else if (rect.y < viewRect.y){
|
24 | y = rect.y; |
25 | } else if (rect.y > (viewRect.y + viewRect.height - rect.height)){
|
26 | y = rect.y - viewRect.height + rect.height; |
27 | } |
28 | |
29 | viewport.setViewPosition(new Point(x,y)); |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1004329 |
| Snippet name: | scrollRowToVisible |
| Eternal ID of this version: | #1004329/1 |
| Text MD5: | 5f5773a6441c87f2deaeca09cc0dca15 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-08-13 15:54:05 |
| Source code size: | 939 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1178 / 1069 |
| Referenced in: | [show references] |