I have a JTable where in one column the values are displayed in the following format:
423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
I am wondering if it is possible to display values in square brackets in RED?
Over the past few days, I have been looking for search queries and found several examples showing how to set the "background" of a cell, but not how to change the font of a cell, especially not a specific part of the text.
public class myTableCellRenderer
extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
Component c =
super.getTableCellRendererComponent(table, value,
isSelected, hasFocus,
row, column);
if (column == 3) {
c.setForeground(Color.YELLOW);
c.setBackground(Color.RED);
}
return c;
}
Is it possible to change part of the text to a different color (i.e. text that is in square brackets).
Edit
, , - , ( ). , , , , 3.
:
product_id |product_name| invoice_numbers
12 | Books | 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
323 | Videos | 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]
4434 | Music | 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)]