java - How to use HTML in JTable custom renderer
问题描述
When using HTML in my JTable cells it will be displayed as
<html><b>Example</html></b>
and not with the proper html styles. I read that default renderers work with html text. How do i change my custom renderer to display HTML correctly ?
My Jtable:
tab_months = new JTable(tabmod_months) {
@Override public Component prepareRenderer(TableCellRenderer renderer,
int row,
int col){
Component c = super.prepareRenderer(renderer, row, col);
int selCol = tab_months.getSelectedColumn();
int selRow = tab_months.getSelectedRow();
if ( selCol != -1 && selRow != -1 ){
if (row == selRow){
c.setBackground(new Color(163,198,255));
} else {
c.setBackground(new Color(255,240,245));
}
}
if (row>=0 && row<listOpenmonths.size()+1) {
setToolTipText(listOpenmonths.get(row).getmonthsString());
}
return c;
}
};
解决方案
Found the problem: my html tag was inside of the string and it wasn't recognized...changed the string format and it worked. Thank you !
推荐阅读
- glsl - 格子玻尔兹曼 WebGL 翻译结果到处都是 NaN
- django - 如何使用 Django 进行 URL 屏蔽?
- android - Room/sqlite 数据库锁和隔离级别
- ios - Xcode 11.0 beta 5 中没有这样的模块“Firebase”错误
- fiware - 我正在尝试使用 FIWARE token_script.sh 文件获取 X-Auth-Token 但它给了我一个空令牌
- android - 无法将 Activity 投射到片段中的接口
- javascript - VueJS 组件 prop 仅在重用时显示最后一个 JSON 条目
- python - 如何通过 Python Pronouncing 库中的音素搜索特定单词?
- python - 在文件中查找多行文本
- makefile - Make:避免在多个 Makefile 中具有相同目标的问题