• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JCheckbox not getting checked in JTable

 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me I have JCheckbox in a JTable
I am using a Customized Table Model - Abstract Table Model but the Issue is that the Checkbox is not getting checked .


Can anyone please help me.
I have not posted this Issue in any other forums.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a small demo program, just a Jframe with single column (checkbox) JTable/scrollpane,
include your Customized Table Model, make sure it compiles/runs/displays the problem,
then post that code
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have already created that it is working fine in that , but in my application it is not working.
Please help.


 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does getValueAt return for that column?

When you click the check box, the model's setValueAt method is called for that cell with the new selected state of the check box, as a Boolean. For instance, checking would call setValueAt(row, column, Boolean.TRUE). Afterwards, the getValueAt method is called to ask for the new value. If that still returns Boolean.FALSE then the check box will not be checked.

Rohit Kedia wrote:I have not posted this Issue in any other forums.

Are you sure? What about this? Is this not the same issue? Apart from BeForthrightWhenCrosspostingToOtherSites we also have a policy to UseOneThreadPerQuestion.
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apology as I am new to the Forum , I will keep note of these from next time.

These are the code snippets can you have a look into these as y they are not working




 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rohit Kedia wrote:y

Please UseRealWords: "why".

Ok, so getValueAt(x, 10) returns whether or not the PubValueObject for that row has a return value of GlobalConstants.YES_VAL for its getUrlInd(). That means that setValueAt(b, x, 10) should also modify this value.

In your setValueAt method you use Boolean.parseBoolean(str). str is still null so that will return false. Use the actual value instead:
By the way, are you not missing setting values for other columns?

Another note: do you really want to return "N/A" for all other columns than column 10? And please use Boolean.TRUE instead of new Boolean(true), Boolean.FALSE instead of new Boolean(false) and Boolean.valueOf(b) instead of new Boolean(b).
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the other codes are missing as the column count is 14 I just removed them to as the list was long.
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sir. I am really really very Thankful.. and my sincere apologies for not complying with the policies.
I will try to comply next time onwards.
I am really very very sorry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic