• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree node with 2 JCheckbox and 1 JTextfield

 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to build a JTree node with 2 JCheckBoxes amd 1 JTextField.
I have implemented my TreeCellRenderer class which extends DefaultTreeCellRenderer and able to display the node by adding the three components (JCkeckBox and JTextField) in a JPanel.
JTree is implementing Mouse Listener.
CheckBoxes are fine,but, I am not able to edit the JTextField.
To find out which Checkbox is clicked, I am using getX(). Is there a better way to do it?
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
for editing, you need to implement the TreeCellEditor, not (only) the TreeCellRenderer. I wonder why that works for JCheckBox? The default TreeCellEditor for JTree is a JTextField, anyway, I suppose. are your nodes mutable?
cheers
Chantal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!