BeansBinding JTable in NetBeans

I want to display the beans list in JTable. The idea is that each column will be a preselected field in the bean, and each row will be a bean in the List. Slide # 32 looks very promising: http://swinglabs.org/docs/presentations/2007/DesktopMatters/beans-binding-talk.pdf

However, NetBeans is not very friendly allowing me to assign a bean field to a column. I can right-click JTable and click Bind-> Elements and link it to my beans list. However, he will not allow me to indicate what happens in each column. The only option is to create a binding that makes NetBeans pretty much useless for this type of thing.

Is there any detail I am missing? It seems that JTable BeansBinding in NetBeans is just broken.

thanks

+3
source share
3 answers

I have a job. You cannot use the "Bind" option for JTables. Here's how to make it work:

  • Right click on JTable.
  • Click "Table Content."
    • Binding Source: Form
    • Binding expression: $ {var} (where var is the name of the beans list).
  • Click the Columns tab.
  • Match the column to the expression. It should look something like this: $ {id} not $ {var.id}.

Note. Each field displayed in a column must have a getter.

+6
source

IDE , .

Glazed Lists beans . 2 , , . 15 , , , - , , .

+4

. - :

list1 = ObservableCollections.observableList(new ArrayList<Person>());

. bean, , set , ,

private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

public void addPropertyChangeListener(PropertyChangeListener listener) {
    changeSupport.addPropertyChangeListener(listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener) {
    changeSupport.removePropertyChangeListener(listener);
}

, -

public void setFirstName(String firstName) {
    String oldFirstName = this.firstName;
    this.firstName = firstName;
    changeSupport.firePropertyChange("firstName", oldFirstName, firstName);
}
0
source

Source: https://habr.com/ru/post/1713195/


All Articles