Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1358 > unrolled thread
| Started by | "yancheng.cheok" <yancheng.cheok@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:32 +0000 |
| Last post | 2011-04-27 15:32 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.gui
converting selected col i "yancheng.cheok" <yancheng.cheok@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
Re: converting selected c "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
| From | "yancheng.cheok" <yancheng.cheok@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | converting selected col i |
| Message-ID | <1175434270.347590.220180@p77g2000hsh.googlegroups.com> |
To: comp.lang.java.gui during sorting, the jTable row index no longer match to its model. hence, i will need to perform the following coversion. final int row = jTable1.getSelectedRow(); final int modelIndex = jTable1.getRowSorter().convertRowIndexToModel(row); however, for the col index, it will also no longer match to its model col index, the user is dragging around the cols. so, how can i concerted the selected col index to model's? thank you. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Re: converting selected c |
| Message-ID | <1175447997.314274.118050@p15g2000hsd.googlegroups.com> |
| In reply to | #1358 |
To: comp.lang.java.gui On Apr 1, 7:31 am, yancheng.ch...@gmail.com wrote: > during sorting, the jTable row index no longer match to its model. > hence, i will need to perform the following coversion. > > final int row = jTable1.getSelectedRow(); > final int modelIndex = > jTable1.getRowSorter().convertRowIndexToModel(row); > > however, for the col index, it will also no longer match to its model > col index, the user is dragging around the cols. so, how can i > concerted the selected col index to model's? > > thank you. Hi Yancheng, Try something like this, where columnIndex is your selected column index. TableColumn column = jTable1.getColumnModel().getColumn(columnIndex); int modelColumnIndex = column.getModelIndex(); Cheers, Dan Andrews ------------------- http://www.ansir.ca --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web