我用paint(Graphics g, JComponent c)方法绘制报表表头,编译时提示:未使用参数C
运行时表头无法显示且提示:UIDefaults.getUI() failed: no ComponentUI class for: ...
java.lang.Error ...
请问:参数C的作用,如何修改这段代码?谢谢!(注:代码来自http://www.54bk.com/?uid-776-action-viewspace-itemid-30520)
public static ComponentUI createUI(JComponent c) {
return new GroupableTableHeaderUI();
}
public void paint(Graphics g, JComponent c) { //提示:未使用参数C TableColumnModel cm = header.getColumnModel();
if (cm.getColumnCount() > 0) {
Rectangle clip = g.getClipBounds();
Point left = clip.getLocation();
Point right = new Point(clip.x + clip.width - 1, clip.y);
int cMin = header.columnAtPoint(left);
int cMax = header.columnAtPoint(right);
if (cMax == -1) {
cMax = cm.getColumnCount() - 1;
}
int columnWidth;
Rectangle cellRect = header.getHeaderRect(cMin); Set done = new HashSet();
for (int column = cMin; column <= cMax; column++) {
TableColumn aColumn = cm.getColumn(column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth;
paintCell(done, g, cellRect, column);
cellRect.x += columnWidth;
}
rendererPane.removeAll();
}
}
运行时表头无法显示且提示:UIDefaults.getUI() failed: no ComponentUI class for: ...
java.lang.Error ...
请问:参数C的作用,如何修改这段代码?谢谢!(注:代码来自http://www.54bk.com/?uid-776-action-viewspace-itemid-30520)
public static ComponentUI createUI(JComponent c) {
return new GroupableTableHeaderUI();
}
public void paint(Graphics g, JComponent c) { //提示:未使用参数C TableColumnModel cm = header.getColumnModel();
if (cm.getColumnCount() > 0) {
Rectangle clip = g.getClipBounds();
Point left = clip.getLocation();
Point right = new Point(clip.x + clip.width - 1, clip.y);
int cMin = header.columnAtPoint(left);
int cMax = header.columnAtPoint(right);
if (cMax == -1) {
cMax = cm.getColumnCount() - 1;
}
int columnWidth;
Rectangle cellRect = header.getHeaderRect(cMin); Set done = new HashSet();
for (int column = cMin; column <= cMax; column++) {
TableColumn aColumn = cm.getColumn(column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth;
paintCell(done, g, cellRect, column);
cellRect.x += columnWidth;
}
rendererPane.removeAll();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货