how to set different row color in jTable

Jtable retreiving data (Swing / AWT / SWT / JFace forum at JavaRanch)

# table = new JTable( … )
# {
# public Component prepareRenderer( TableCellRenderer renderer, int row, int column)
# {
# Component c = super.prepareRenderer(renderer, row, column);
#
# // Alternate row color
#
# if (!isRowSelected(row))
# c.setBackground(row % 2 == 0 ? getBackground() : Color.LIGHT_GRAY);
#
# return c;
# }
# };

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

What is 3 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)