codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Coloring row problem of JTable  enot at 07:44 on Wednesday, March 26, 2008
 

Hi!
I'm the beginer and have a problem while coloring rows in my table. The problem is as follows:
i need to color the whole row when i click a single cell of this row. Everything is ok until i click another cell of another row. When i do it all the row between first and last clicked become colored!
I tryed manipulating table.setSelectionMode(i) - but nothing!

My very simple code:

DefaultTableCellRenderer renderer = new DefaultTableCellRenderer()
{
public Component getTableCellRendererComponent(JTable table,Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent(table,value, isSelected, hasFocus, row, column);
if (isSelected) {cell.setBackground(Color.LIGHT_GRAY);return cell;}
return cell;
}
};

for(int i=0; i<table.getColumnCount(); i++)
{
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
}


Please help!
PS I cant use Ctrl button in my program because all the changes in table are in table.isEnable(false)-mode-it is the condition of my work.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  developing a bookselling system using jsp: need help in fixing database error
•  Accessing user control in master page from any content page
•  Displaying HTML formatted text in a aspx page
•  Coloring row problem of JTable
•  TM symbol is not displayed correctly.
•  How to time out an operation?
•  Getting dat a from datagrid
•  Re: Java script: Disable
•  Re: file upload


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008