是否可以在JXTreeTable中使用可变大小的行,如果是,那么如何? ,我正在尝试在TreeExpansionEvent上更改行的高度(如下所示):
public void treeExpanded(TreeExpansionEvent e)
{
for (int i = 0; i < table.getRowCount(); i++) {
System.out.println("Value of img"+table.getValueAt(i,22));
if (table.getValueAt(i, 22) != null) {
table.setRowHeight(i,40);
table.repaint();
table.revalidate();
}
}
}
在运行代码时,我得到以下异常:
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: variable height rows not supported
at org.jdesktop.swingx.JXTreeTable.setRowHeight(JXTreeTable.java:1321)
at ims.View.ViewImages.treeExpanded(ViewImages.java:559)
at org.jdesktop.swingx.event.TreeExpansionBroadcaster.fireTreeExpanded(TreeExpansionBroadcaster.java:85)
at org.jdesktop.swingx.event.TreeExpansionBroadcaster.treeExpanded(TreeExpansionBroadcaster.java:68)
at javax.swing.JTree.fireTreeExpanded(JTree.java:2766)
at javax.swing.JTree.setExpandedState(JTree.java:3616)
at org.jdesktop.swingx.JXTreeTable$TreeTableCellRenderer.setExpandedState(JXTreeTable.java:2921)
at javax.swing.JTree.expandPath(JTree.java:2204)
at javax.swing.plaf.basic.BasicTreeUI.toggleExpandState(BasicTreeUI.java:2266)
at javax.swing.plaf.basic.BasicTreeUI.handleExpandControlClick(BasicTreeUI.java:2253)
请帮助!
答案 0 :(得分:2)
JXTreeTable
不支持变量行高。 setRowHeight()州的文档:
抛出UnsupportedOperationException,因为变量高度行是 不支持。
另请参阅@ thread @kleopatra关于此功能的答案。