I have a Jtable and I want to highlight a row by adding a border to the row. I have extended a DefaultTableCellRenderer and I figure the work needs to be done in the getTableCellRendererComponent method.
I’m guessing that since there doesn’t seem to be a concept of a row that I need to create a custom border for the individual cells in the row. Something like a left side, top, and bottom for the first cell, a top and bottom for all the inner cells, and a top, bottom, and right side for the last cell in the row. I’m having problems finding out how to go about actually executing the thought process. I’m not sure how to use the setBorder() method or if that’s even the direction I need to take.
You have the correct idea in mind, you will need to set the border on the label in the cellrenderer depending on where it is in the table(i.e. edge, center etc).
Take a look at matteborder. You can specify which areas to draw a border along w/ width and color.