easy and fast JTree Cell Editor

后端 未结 2 585
闹比i
闹比i 2020-12-03 23:26

I have a JTree with a custom TreeModel and a custom TreeRenderer. The Tree Model contains a bunch of objects of different types. One of these types is displayed differently

2条回答
  •  醉梦人生
    2020-12-03 23:29

    A custom editor is required. MyTreeCellEditor, illustrated here, shows one approach. It updates an arbitrary attribute of a userObject, which is named Resource and held in a DefaultMutableTreeNode. As the attribute is text, it also uses the DefaultTreeCellRenderer. Your custom TreeModel probably manages a similar userObject that is the parent of your "objects of different types."

提交回复
热议问题