wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Please Help me JCheckBox in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Please Help me JCheckBox in JTable" Watch "Please Help me JCheckBox in JTable" New topic
Author

Please Help me JCheckBox in JTable

Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
Hi ,
Please help me out ... I need how to add a Jcheckbox in a JTable column.
I tried to add but the checkbox was not getting checked or set.

Please help
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
did you read Sun's JTable tutorial? (it contains a checkbox column)
Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
Hey thanks for the Reply,
I have read it .. but found it difficult to implement.

In my Table I am getting the Check box by adding the method



but the problem is my that check box is not getting checked after loading the Table and neither it is getting checked on clicking on the Check box please help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

You should also override setValueAt so that the return value of getValueAt for that cell will return false. In other words, if before Variable a != Y for that row, then you should change your model's data such that Variable a == Y afterwards. Otherwise the model will still return Boolean.FALSE for that cell and the check box will remain unchecked.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> but the problem is my that check box is not getting checked after loading the Table and neither it is getting checked on clicking on the Check box please help.

the main problem, for me, is that you've decided to post your problem in multiple forums,

http://www.java-forums.org/awt-swing/28154-jcheckbox-jtable-column.html

and I have absolutley no intention of spending one more second of my time trying to resolve your problem here,
when the problem may have been already resolved on other forum/s
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Michael refers to Be Forthright When Cross Posting To Other Sites.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please Help me JCheckBox in JTable