JTables are components of the Java Swing API that render a table on-screen in a Java program. A JTable consists of rows and columns, and the intersection of each is referred to as a cell. You can change a cell's background colour, information and more by modifying an active instance of a JTable object.
- Skill level:
Other People Are Reading
Navigate to your JTable object. It will be declared with the syntax "JTable <name> = new JTable(<value>);" where "<name>" is the name of the JTable object and "<value>" specifies the parameters that the table was constructed with.
Identify the table row and column that hold the cell you would like to modify. Begin a new line of code that reads:
JCell cel; = JTableName.LocateCell(row#,column#);
Replace "row#" with the number of the row and "column#" with the number of the column.
Modify the column's background colour. Type:
cell.BG = "######";
Replace "######" with the hexadecimal colour code for your background. For example, "000000" is black while "FFFFFF" is white. You can find a full chart of colour codes online (see Resources).
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for