Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to change the JTable selection when is unebled

427038Aug 6 2008 — edited Aug 6 2008
Hi!

I have creted a swing database applcation with Nerbeans. (CRUD)
In a Master / Detail form for the entity clases from database I want to view the record detail, and after a buton press to be editable the records : te selected record.
So I have created an Edit JToggleButton.
I look for all day how can I bind. The most acceptable solution is to bind the edit button selected propertie to the mastertable.enabled propertie.
But when is not enabled the mastertable (JTable), than did notlet me to change my selection, and I need that.

The question can be: How to change the selection when the JTable is not enabled?
Or for witch propertie must bid the edit button selected properties to be not editable the detail textields, check boxes, buttons, and the table editable columns?

.............
masterTable = new javax.swing.JTable();
chbActiv = new javax.swing.JCheckBox();
denumireField = new javax.swing.JTextField();
chEditare = new javax.swing.JCheckBox(); // the ckeck box it was toggle button, but I have changed

// the columns:
columnBinding.setColumnName("Denumire");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${activ}"));
columnBinding.setColumnName("Activ");
columnBinding.setColumnClass(String.class);

binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.denumire}"), denumireField, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue(null);
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${(selectedElement != null) && (enabled)}"), denumireField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.activ}"), chbActiv, org.jdesktop.beansbinding.BeanProperty.create("selected"));
binding.setConverter(ynConverter);
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${(selectedElement != null) && (enabled)}"), chbActiv, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);

chEditare.setText(resourceMap.getString("chEditare.text")); // NOI18N
chEditare.setBorderPainted(true);
chEditare.setName("chEditare"); // NOI18N

binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), chEditare, org.jdesktop.beansbinding.BeanProperty.create("selected"));
bindingGroup.addBinding(binding);




..................

Edited by: matheszabi on 2008.08.06. 15:49
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2008
Added on Aug 6 2008
0 comments
278 views