jtable is not editable

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

jtable is not editable

Postby Sandy » Fri Sep 11, 2009 2:24 am

Hello,

I have model class with an StringArray aaaa:

public class XXX
{
private String info = "Initial";
private boolean gesperrt = false;

private List<String> aaaaa;



I habe a table:


jt_astliste = new JTable();
jt_astliste.setCellSelectionEnabled(true);
jt_astliste.setAutoCreateRowSorter(true);
jsp_astliste.setViewportView(jt_astliste);


I bound the list to a table:

protected BindingGroup initDataBindings() {
BeanProperty<XXX, List<String>> xxxBeanProperty = BeanProperty.create("aaaaa");
JTableBinding<String, XXX, JTable> jTableBinding = SwingBindings.createJTableBinding(UpdateStrategy.READ_WRITE, xxx, xxxBeanProperty, jt_astliste);
//
ObjectProperty<String> stringObjectProperty = ObjectProperty.create();
jTableBinding.addColumnBinding(stringObjectProperty).setColumnName("AAA");
//
jTableBinding.bind();
//
BindingGroup bindingGroup = new BindingGroup();
//
bindingGroup.addBinding(jTableBinding);
return bindingGroup;
}


Now the Problem: The cells are not editable, and I have found now way to persuade the binding.

Could you give me a hint?
Setting a TableCellEditor did not work, setting setCellEditable(true) did not work.

Thanks,
Sandy
________________________________________________________
Sorry for typos and bad English.
You may correct me if you like to.
Sandy
 
Posts: 12
Joined: Tue May 05, 2009 11:38 pm

Re: jtable is not editable

Postby Eric Clayberg » Mon Sep 14, 2009 8:50 am

The basic problem appears to be that you are binding to a String which is an immutable object.

If you bind to an actual model object that contains a string, it should be editable.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest