Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom converter in JGoodies Binding  RSS feed

 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been trying to create a custom JGoodies binding converter with no luck. Currently my model contains properties that are all simple types (strings, integers, etc). Everything is setup such that when a property changes the corresponding JLabel in my GUI changes. Okay...no problem.

But now I want to bind a custom object, not just a string or integer. So, for example I have something like the following:

My current working model class:


But now I'm trying to do something like:



I've thought that I would have to develop a custom converter (extending the com.jgoodies.binding.value.AbstractConverter class) that takes my custom object and converts it into a string representation because I then have:



but this gives me an exception:



Can anyone help?
[ October 26, 2005: Message edited by: David Irwin ]
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should have been obvious:


Caused by: java.lang.ClassCastException: The subject value must be of type HardwareData.
at jhomenet.binding.CustomConverterFactory$DataConverter.convertFromSubject(Unknown Source)
at com.jgoodies.binding.value.AbstractConverter.getValue(AbstractConverter.java:134)


I was getting a class cast exception because the first conversion was sending something other than my CustomObject. Now I've removed this excetion and simple returns a "NULL" string instead. Now it works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!