• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting JCheckbox inside JTable and rendering

 
prajna pa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
prajna pa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you really using the == operator on Strings?
 
prajna pa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic