Package Helpers

Examples of Helpers.AuthorTableModel


    private void fillTable(){
        AuthorModel authorModel = new AuthorModel();
      
        List<Author> authors = authorModel.all();
       
        AuthorTableModel authorTableModel = new AuthorTableModel(authors);
        jTable1.setModel(authorTableModel);
    }
View Full Code Here


    private void fillTableSearch(String author_name){
        AuthorModel authorModel = new AuthorModel();
      
        List<Author> authors = authorModel.whereFullName(author_name);
       
        AuthorTableModel authorTableModel = new AuthorTableModel(authors);
        jTable1.setModel(authorTableModel);       
    }
View Full Code Here

        if (row == -1) {
            JOptionPane.showMessageDialog(this, "Select a row");
           
        }
        else{
        AuthorTableModel tableModel = (AuthorTableModel) jTable1.getModel();
        Author author = tableModel.getRowObject(row);
        txtAuthorAge.setText(String.valueOf(author.getAge()));
        txtAuthorFullName.setText(author.getFull_name());
        txtAuthorDetails.setText(author.getDetails());
        txtAuthorLocation.setText(author.getLocation());
                  
View Full Code Here

        jDialog1.dispose();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
        //We need author object. Lets again fetch it from tablemodel
        AuthorTableModel tableModel = (AuthorTableModel) jTable1.getModel();
        int row = jTable1.getSelectedRow();
        int age = 0;
        Author author = tableModel.getRowObject(row);
        author.setFull_name(txtAuthorFullName.getText());
       
        try{
        age = Integer.parseInt(txtAuthorAge.getText());
        }catch(NumberFormatException e){
            System.err.println("number not given, taken as 0");
            //e.printStackTrace();
        }
        author.setAge(age);
      
        author.setLocation(txtAuthorLocation.getText());
        author.setDetails(txtAuthorDetails.getText());
       
        AuthorModel authorModel = new AuthorModel();
        int update_flag = authorModel.update(author);
        if(update_flag == 1){
            //tableModel.fireTableRowsUpdated(row-1, row+1);
            tableModel.fireTableDataChanged();
            jDialog1.dispose();
            JOptionPane.showMessageDialog(this, "Author "+author.getFull_name()+" updated!", "Success!", JOptionPane.INFORMATION_MESSAGE);
        }
       
    }//GEN-LAST:event_btnUpdateActionPerformed
View Full Code Here

TOP

Related Classes of Helpers.AuthorTableModel

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.