/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package javaapplication2; /****************************************************************************************** CMap1对CMap地实现 span( ) 表示合并的单元格的列,返回的是合并的格数。 visibleCell() 表示要渲染的格。返回的渲染的开始格的行。 本程序的table是16行10列,合并的单元格是第一列和最后一列(最后一列是第10列)每两个行。 *******************************************************************************************/ import javax.swing.*; import javax.swing.table.*; class CMap1 implements CMap { public int span(int row, int column) { if( column == 0 || column == 9 ) return 2; return 1; } public int visibleCell(int row, int column) { if( ( ( row >= 0 ) && ( row = 2 ) && ( row = 4 ) && ( row = 6 ) && ( row = 8 ) && ( row = 10 ) && ( row = 12 ) && ( row = 14 ) && ( row >>row = " + row + "column = " + column ); return row; } }