This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problem with a JTable

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello !
When I select a cell for coloring it, I use the methods addColumnSelectionInterval and addRowSelectionInterval for selecting it. (because I don't know how doing that otherwise)
But there is a problem. For exemple, when I select the cell at the column 2 and at the row 3 and the cell at the column 3 and at the row 2, the cell at the row 2 and at the column 2 is selected( the cell 3,3 too)
How can I prevent that ?
(sorry for my bad english)
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It's been a while since you posted, but for posterity's sake..
You might try using setColumnSelectionInterval() instead of
addColumnSelectionInterval(), and the same for the row.
//ebu
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having the same problem. It appears to be a problem with JTable and the selection model it implements.
In your example the JTable sees rows 2 and 3 and columns 2 and 3 as being selected.
Assuming you have cell selection enabled on the table then JTable sees the intersection of the selected rows and columns as being selected and so cells (2,2), (2,3), (3,2) and (3,3) are displayed as selected. If you try to select cell (2,4) then you should see that the selected cells now appear as (2,2), (2,3) and (2,4) as you are effectively selecting column 4 and deselecting row 3.
I don't know the solution to this one yet, other that overriding the selection yourself but I am continuing to look into it.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was wonder how did you get the table inside the frame amd panel. and my headers have disappeared also
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic