Skip to content
Advertisement

Is there a way that i can highlight or colour various table rows based on data entered in textfield?

What i’m trying to do it’s highlight the serial number that i scan from a box of items.

So when i scan the S/N. My idea is that the table, which contains the items in the box, change their color. My english sucks, so i think images can explain my idea in a better way.

So my code does the following:

First i load the table with the info from the box 1 (“Gaveta”):

http://prntscr.com/o4ykdy

Then when i filter the S/N of the item in the box:

http://prntscr.com/o4yly4

i face my problem, the search paints the correct S/N but it damages my tablemodel.

My code:

Data search:

public void buscarNumeroSerie (String nserie) { try {

Table Renderer:

public class ClaseColor extends DefaultTableCellRenderer {

return this;

} }

What i’m trying to do is paint every S/N that matchs with the textField “Serial Number” which does the search.

Something like this:

http://prntscr.com/o4ynui

so any new S/N i search, get a mark while i keep scanning S/N, and then the S/N that are not marked, are eliminated from the table.

Advertisement

Answer

Final update at this, i fixed my problem changing the value at the following line:

for

Finally !

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement