This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Selecting a row in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Selecting a row in JTable" Watch "Selecting a row in JTable" New topic
Author

Selecting a row in JTable

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
Hi i have this problem,

When i select a row in my JTable, the full row is not getting highlighted as in MS-Excel.

Kindly provide your help.
I wrote the following code:
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Kindly provide your help.

the snippet you posted works OK for me (1.5.0_05)
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
Hi, Thanks for the reply...

But there is a problem.If you select row 1 from column 1, it will select the first row.

But if you select row 1 from column 2, first row will be selected except that column. This should not happen.

When we welect row 200 from column 1, only row 200 should be selected. (Just like MS-Excel)

When we select row 200 from column 2, only that cell should be highlighted not the full row.

Kindly post your reply. This is required on an urgent basis.
Thanks, Vijay
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Well, I'm lost.

selecting any cell, regardless of column, highlights the entire row.

but this is not like excel (Excel 2000, anyway) - to select the entire row
you need to click the row header.

from your description you would need to use a custom cellRenderer
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
Hi,
Thanks for your input.
I have solved the problem.
But one more problem has arised.
I select a row and it gets highlighted. After this i invoke a Find/Replace function.

When i click Find Next button without entering any data in Find text box, the cell selection toggles in all cells but the background color of the cells is not getting changed as in Excel

How to change that? Kindly reply
Thanks
[ February 06, 2007: Message edited by: vijaychandran rajagopalan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Selecting a row in JTable
 
Similar Threads
Jtable CellEditor
JTable Problem!
JTable
JScrollPane
JTABLE PROBLEM