Package org.jdesktop.swingbinding

Examples of org.jdesktop.swingbinding.JTableBinding


         * Creates new form FeuilleNoteView
         */
        private void init() {
                initComponents();
                // create the binding from List to JTable
                JTableBinding tb;
                tb = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ_WRITE, feuilleModel.getNoteEleves(), table);
                // define the properties to be used for the columns
                BeanProperty nome = BeanProperty.create("eleve.nom");
                BeanProperty prenome = BeanProperty.create("eleve.prenom");
                BeanProperty notee = BeanProperty.create("note");

                BeanProperty envoi = BeanProperty.create("envoie");

                // configure how the properties map to columns
                tb.addColumnBinding(nome).setColumnName("Nom").setEditable(false);
                tb.addColumnBinding(prenome).setColumnName("Prénom").setEditable(false);
                JTableBinding.ColumnBinding col_note = tb.addColumnBinding(notee);
                col_note.setColumnName("Note");
                col_note.setEditable(true);
                col_note.setColumnClass(String.class);
                // definie le validateur a utiliser par la vue pour valider les valeurs
                col_note.setValidator(EleveNote.getNoteValidator());
                // Listener pour ecouter les changement de valeur afin de gerer coté client le verification des valeur rentrer
                col_note.addBindingListener(new BindingListener() {
                        @Override
                        public void bindingBecameBound(Binding binding) {
                        }

                        @Override
                        public void bindingBecameUnbound(Binding binding) {
                        }

                        @Override
                        public void syncFailed(Binding binding, SyncFailure failure) {
                        }

                        @Override
                        public void synced(Binding binding) {
                        }

                        @Override
                        public void sourceChanged(Binding binding, PropertyStateEvent event) {
                        }

                        @Override
                        public void targetChanged(Binding binding, PropertyStateEvent event) {
                                if (binding.getTargetValueForSource().failed()) {
                                        JOptionPane.showMessageDialog(jScrollPane1, binding.getTargetValueForSource().getFailure().getValidationResult().getDescription(),
                                                "Valeur incorrecte",
                                                JOptionPane.ERROR_MESSAGE);
                                }

                        }
                });
                tb.addColumnBinding(envoi).setColumnName("A envoyer").setEditable(true).setColumnClass(Boolean.class);

                // realize the binding
                tb.bind();
        }
View Full Code Here

TOP

Related Classes of org.jdesktop.swingbinding.JTableBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.