• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree with multiple editor types

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a JTree in my GUI. In the data model there are four types of leaf nodes - text, numeric, date/time and enumeration. I want to have a simple text field editor for the text and numeric, a JSpinner widget for date/time editing and JComboBox for enumerations. I see tons of examples where one editor type is specified. Can I specify three different editor classes for a JTree?

Any ideas on this are greatly appreciated,
Ken
 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TreeCellEditor is an interface with only one method: getTreeCellEditorComponent.
That method takes the leaf and row as input parameters; you can create your own extension of TreeCellEditor and create the three different editors as instance variables. then your getTreeCellEditorComponent() method just calls the appropriate one of those editors based on the leaf and row.
reply
    Bookmark Topic Watch Topic
  • New Topic