[英]Display only the right side of long Text in JTable
is there any posibility to display only the right side of an long text in a JTable? 是否有可能仅在JTable中显示长文本的右侧? eg i have this long string:
例如我有这个长字符串:
asldjklasjdklasjdklasjdlkasjkldjaslkjdklasjdklasjdlkajskldjaslk
in my table is displayed: 在我的表中显示:
asldjklasjdklas...
but i want 但我想要
...jdlkajskldjaslk
to just make the column right aligned did not work :( 只是使列右对齐不起作用:(
您可以尝试使用“ 左点渲染器” 。
You have to create your own TableCellRenderer implementation: 您必须创建自己的TableCellRenderer实现:
class MyTableCellRenderer implements TableCellRenderer {
...
}
and replace the JTable default renderer with it: 并用它替换JTable默认渲染器:
jTable.setDefaultRenderer(new MyTableCellRenderer());
or, if you want to set it for just some column, say, the first: 或者,如果您只想为某些列设置它,例如,第一列:
jTable.getColumnModel().getColumn(1).setCellRenderer(new MyTableCellRenderer())
Left Dot Renderer , previously mentioned by @camickr, is a TableCellRenderer implementation. @camickr先前提到的Left Dot Renderer是TableCellRenderer的实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.