• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

inserting JCheckbox inside JTable and rendering

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.










 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80281
432
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you really using the == operator on Strings?
 
prajna pa
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic