aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes inserting JCheckbox inside JTable and rendering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "inserting JCheckbox inside JTable and rendering" Watch "inserting JCheckbox inside JTable and rendering" New topic
Author

inserting JCheckbox inside JTable and rendering

prajna pa
Ranch Hand

Joined: Oct 04, 2012
Posts: 36
i had a problem in implementing a check box inside a table and also to give actions for that..


i got a table having 4 columns and 47 rows and i need to change the color of the particular row
when i select the check box and change the color of the row when i deselect it hereby i am pasting the code... please help me

Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

So, what is the exact issue that you are getting? Does the check box appear? What happens when you click on it?
Also, in your editor, why do you keep creating new instances of JCheckBox in the getTableCellEditorComponent method? I think that is not needed.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
prajna pa
Ranch Hand

Joined: Oct 04, 2012
Posts: 36
to ranganathan sir


sir...
Actually i got a table of 4 columns and 47 rows .

here i got the check box but i am facing some problem in that .

i need like this if am selecting the check box i should change the color of another cell and if i unchecked it should change to different color..


so pl z help me.. i think you got my problem
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

prajna pa wrote:
here i got the check box but i am facing some problem in that .

What is that problem exactly? Did you run the program? Do you get an exception?
Plainly asking us to help by posting 550+ lines of code is not going to work.

Create a SSCCE and post the code.
prajna pa
Ranch Hand

Joined: Oct 04, 2012
Posts: 36
i am sending you the code i haven't got any exception but still it is not working properly rendering.

i will post the three classes which i had created for rendering ,check box editor and check box renderer.










m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 155
if(value =="different" || isJcheckbox(value)){

- Renderer is wrong, there no reason to use Renderer for built_in Boolean support in JTable

- otherwise must be seOpaque

- why did you simulating value for JTableHeader in JTables cell(s)


___________________________________________________________________________

- never to modify cell value in Renderer

- this is job for XxxTableModel, store there proper value in proper class

- Renderer is about formatting, highligting, coloring,... value stored in model

- use prepareRenderer for row coloring

- convert view to model
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Are you really using the == operator on Strings?
prajna pa
Ranch Hand

Joined: Oct 04, 2012
Posts: 36
facing a problem in rendering.

i need to change the color of the row to blue when the check box is selected.
and red when it is deselected.so pl z help me thanking you in advance... here i am posting my code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inserting JCheckbox inside JTable and rendering