Cannot bind text field to selected item in JTable in NetBeans

Posted by titaniumdecoy on Stack Overflow See other posts from Stack Overflow or by titaniumdecoy
Published on 2010-04-01T06:21:57Z Indexed on 2010/04/01 6:23 UTC
Read the original article Hit count: 652

Filed under:
|
|
|

I am trying to use NetBeans to bind a JTextField to the selected element of a JTable.

The JTable gets its data from an AbstractTableModel subclass which returns Cow objects. At present, each Cow object is displayed as a string through its toString method.

The binding seems obvious but does not work; the bound value of the text field is always null.

I bound the text property of the JTextField in NetBeans to:

flowTable[${selectedElement.prefix}]

This produces the following line of generated code:

org.jdesktop.beansbinding.Binding binding = 
  org.jdesktop.beansbinding.Bindings.createAutoBinding(
    org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, 
    flowTable, 
    org.jdesktop.beansbinding.ELProperty.create("${selectedElement.prefix}"), 
    courseNameTextField, 
    org.jdesktop.beansbinding.BeanProperty.create("text"));

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about netbeans

Related posts about jtable