aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JCheckbox not getting checked in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JCheckbox not getting checked in JTable" Watch "JCheckbox not getting checked in JTable" New topic
Author

JCheckbox not getting checked in JTable

Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Apr 24, 2010
Posts: 79

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


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
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

Joined: Oct 27, 2005
Posts: 19696
    
  20

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

Joined: Apr 24, 2010
Posts: 79
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

Joined: Apr 24, 2010
Posts: 79
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JCheckbox not getting checked in JTable