swing - How to use TableColumnModelListener to change the column color based on the reposition in java -
i have table 4 columns called id, name, subject, marks
.
if marks below 35, changing marks
column colour red
else black
.
here, have issue if change column position of marks
becoming `black' , 1 there in marks position getting coloured.
i have tried implementing tablecolumnmodellistener
, overridden columnmoved() method. when try column index tablemodel.getcolumnindex("marks")
still giving previous position index not new one.
is there way new column index passing name?
you setting colors in implementation of tablecellrenderer
(possibly deriving defaulttablecellrenderer
). row
, column
indexes reported in gettablecellrenderercomponent
method view indexes, not model indexes. using view index index model, or vice versa.
you can change index view model using of jtable.convertxxxindextomodel
methods, or model view jtable.convertxxxindextoview
(where xxx
row
or column
). see jtable
class documentation more details.
Comments
Post a Comment