在JTable中显示表情符号 [英] Display Emoji character in JTable
问题描述
我想在扬声器角色中显示 JTable
:
@Override
public Object getValueAt ,int col)
{
switch(col){
[...]
case 2:
String symbol =\\\�\UDD0A;
返回状态+符号;
default:
return;
}
}
不幸的是,我只是看到一个方框。我不知道我是否必须设置一个支持该字符的特定字体
或应用其他编码。
对于寻找解决方案的Google员:
我为JTable实现了一个CustomRenderer,如@trashgod sugested。 此处或 here 。
是的,你需要两件事情: / p>
或者,考虑实现图标
接口的 TableCellRenderer
,如此处。图形上下文的填充(Polygon)
和 drawArc()
方法应该产生令人满意的结果。
I want to display loudspeaker character in a JTable
:
@Override
public Object getValueAt(int row, int col)
{
switch (col) {
[...]
case 2:
String symbol = "\uD83D\uDD0A";
return "State " + symbol;
default:
return "";
}
}
Unfortunaly i just see an square box. I'm not sure if i have to set an specific Font
supporting this character or to apply an other encoding.
For Googlers looking for a solution:
I implemented a CustomRenderer for the JTable like @trashgod sugested. Examples are available here or here.
Yes, you'll need two things:
A font containing the required glyph, loaded as shown here.
A
TableCellRenderer
in which to use the font, as shown here.
Alternatively, consider a TableCellRenderer
that implements the Icon
interface, as shown here. The graphics context's fill(Polygon)
and drawArc()
methods should produce a satisfactory result.
这篇关于在JTable中显示表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!