Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1363

Re: converting selected c

From "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this>
Subject Re: converting selected c
Message-ID <1175447997.314274.118050@p15g2000hsd.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1175434270.347590.220180@p77g2000hsh.googlegroups.com>
Date 2011-04-27 15:32 +0000
Organization TDS.net

Show all headers | View raw


  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

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web