[英]Display an icon in a specific JTable cell
我想在特定的JTable
单元格中显示一个图标,而在整个列的单元格中没有相同的图标。
Assuming you've done your research and know how to use custom cell renderers , the basic concept is simple. 假设您已完成研究并知道如何使用自定义单元格渲染器 ,则基本概念很简单。
public Component getTableCellRendererComponent(
JTable table, Object color,
boolean isSelected, boolean hasFocus,
int row, int column) {
// Prepare renderer as usual...
// Check to see if the current row/column is within
// the acceptable range...
// It would be usful if this information was coming from
// some kind of model
if (row == iconRow && column == iconColumn) {
// Apply the icon for this cell renderer
}
return this;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.