1

I'm currently working on a Desktop Application in Java using Swing. I’m using the beansbinding framework by jdesktop.org to synchronize the state of GUI components and data objects. However I’m running into troubles with the framework, forcing me to manually transfer state information between GUI components and data objects back and forth.

Are there alternatives to the beansbinding framework (which is used by NetBeans too I think?)? Is there some strategy that you can recommend (like not using bindings at all? what to do instead?)?

In case you wonder what problems I do face with beansbinding:

  • it replaces my TableModel inside JTables (so I can’t use my own or delete rows)
  • certain properties are not accessible or available, like selectedItem or selectedObject (at least consistenly across JComboBox, JList, etc.)
  • certain properties are either read only or write only (like selectedItem or selectedObject)
  • I can bind special values for the value null, but I can’t for example map numbers in a list to strings in a JComboBox using a custom mapping function or something (I know that I can create a special class with an appropriate toString method, however this forces me to create special wrapper objects for my datasets)
  • ...
divibisan
  • 11,659
  • 11
  • 40
  • 58
scravy
  • 11,904
  • 14
  • 72
  • 127

1 Answers1

2

Though usable, Beansbinding is dead - it was artificially pushed into 1.x state when it was far from having earned that version number and not much changed since then. Whatever problems you discover, they will not be fixed - except you do it yourself :-) As to the particular bullets:

  • the overall idea is that the TableModel is-a List of objects, its columns bound to properties (bean or EL) of the object. It's typically an ObservableList which does supports modifications.
  • JComboBox is a construction site. Selection binding in JList/JTable are available and consistent
  • making (single) selection writable isn't such a big deal (experimented with an adapter for JXTable in the incubator). Haven't seen a write-only property, which do you mean?
  • as with every binding framework, you need Converters to map values types (that's unrelated to rendering, btw, though plays a role in editing)

The obvious current alternative is JGoodies Binding. Didn't look into it for a while, but seen that it came out with a new version recently, so definitely under development and used. A future alternative might be fx binding - it's still in its infancy, waiting for kind souls to build some usable framework around its barebones.

kleopatra
  • 51,061
  • 28
  • 99
  • 211