Using the Static method, placed in the common tool class Myutil, just add myUtil.makeface after the table data is generated; you can:
Public Static Void Makeface (JTable Table) {
try {DefaultTableCellRenderer tcr = new DefaultTableCellRenderer () {public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {if (row% 2 == 0) setBackground (Color.white); / / Set the odd row of bottom color else if (row% 2 == 1) SetBackground (New Color (206, 231, 255)); // Setting an even line of bottom color Return Super.getTableCellrendERComponent (Table, Value, ISSelected, Hasfocus, Row, Column); }}; For (int i = 0; i
}
// ... 省略 JTABLE Data Display Code ... // Add:
MyUtil.makeface (jtable1);
http://bjgx.nese.net