Form1JFrameAppFxWebService.java (AppFxWebService)

package appfxwebserviceclientjaxws;

import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.xml.bind.JAXBException;

public final class Form1JFrame extends javax.swing.JFrame {

    final DefaultListModel listModel = new DefaultListModel();
    final DefaultTableModel tableModel = new DefaultTableModel();
    final DefaultTableModel tableModelEventExpense = new DefaultTableModel();
    final Boolean useHttps = false;
    String databaseToUse = "";
    
    //Declare this to represent the web service, AppFxWebService, through which
    //you will access the Infinity application.
    AppFxWebService _appFxWebService = new AppFxWebService();
    //ClientAppInfoHeader will be used to hold the client application name that 
    //identifies your custom client software for auditing purposes within the 
    //Infinty database.  It also holds a database identifier to help point to 
    //the correct database.
    ClientAppInfoHeader _clientAppInfoHeader = new ClientAppInfoHeader();
     
    //Variables used to track the event info
    Boolean _eventsLoaded = false;
    String _eventId = "";
    String _eventName  = "";

   
    public class SelectionListener implements ListSelectionListener {
        JTable table;
        SelectionListener(JTable table) {
            this.table = table;
        }
        @Override
        public void valueChanged(ListSelectionEvent e) {
            try {
                loadExpenses(jTableEvents.getValueAt(jTableEvents.getSelectedRow(), 9).toString());
            } catch (JAXBException ex) {
                Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
   
    public void editExpense(String expenseId) throws JAXBException, IOException{
        //Create Strings for the field values to pass to the edit JFrame.
        String exId, exType, vendorId, vendorName, bAmt, amtPaid, comment;
        
        //Populate the Strings to be passed with row information for the
        //selected row. The if-elses are to avoid null values.
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 0) != null) {
           exId = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 0).toString(); 
        }
        else{
            exId = "";
        }
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 1) != null) {
           exType = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 1).toString(); 
        }
        else{
            exType = "";
        }
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 2) != null) {
           vendorId = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 2).toString(); 
        }
        else{
            vendorId = "";
        }
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 3) != null) {
           vendorName = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 3).toString(); 
        }
        else{
            vendorName = "";
        }
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 4) != null) {
           bAmt = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 4).toString(); 
        }
        else{
            bAmt = "";
        }
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 6) != null) {
           amtPaid = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 6).toString(); 
        }
        else{
            amtPaid= "";
        }
        if (jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 9) != null) {
           comment = jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 9).toString(); 
        }
        else{
            comment = "";
        }
        
        //Create an instance of the edit screen, passing the String created in
        //this method along with service infomation.
        EditExpenseJFrame editExpenseScreen = 
                new EditExpenseJFrame
                    (exId, exType, vendorId, vendorName, bAmt, amtPaid, comment,
                  _appFxWebService, _clientAppInfoHeader);
        editExpenseScreen.setEnabled(true);
        editExpenseScreen.setVisible(true);
        editExpenseScreen.toFront();
    }
       
    public void addExpense(String eventId, String eventName) throws JAXBException, IOException{
        //Create an instance of the add screen, passing event and service
        //infomation.
        AddExpenseJFrame addExpenseScreen = 
                new AddExpenseJFrame
                    (eventId, eventName, _appFxWebService, _clientAppInfoHeader);
        addExpenseScreen.setEnabled(true);
        addExpenseScreen.setVisible(true);
        addExpenseScreen.toFront();
    }
    
    public void deleteExpense(String expenseId) throws JAXBException, IOException {
        RecordOperationPerformRequest req = new RecordOperationPerformRequest();
        RecordOperationPerformReply reply = new RecordOperationPerformReply();

        req.clientAppInfo = _clientAppInfoHeader;
        req.id = expenseId;
        req.recordOperationName = "Event Expense: Delete";
        //req.recordOperationID = "eeba73b6-8878-41c5-9730-a3c7f9e64a9f";
        
        //The API utilizes a Request-Response pattern. The pattern consists of 
        //request-response pairs. An operation is called with the request, such 
        //as RecordOperationPerform. The request is passed to the operation.
        //A reply is received. Each request and reply type is tailored to the
        //operation. So, the proxy's RecordOperationPerform operation requires a  
        //RecordOperationPerformRequest and returns a 
        //RecordOperationPerformReply. Since we need to 'delete' a row of data
        //we use a the appropriate record operation/feature named 
        //"Event Expense: Delete" 
        reply = 
        _appFxWebService.getAppFxWebServiceSoap12().recordOperationPerform(req);
        
        JOptionPane.showMessageDialog(this,reply.toString());
        loadExpenses
                (jTableEvents.getValueAt
                (jTableEvents.getSelectedRow(), 0).toString());
    }
    
    public void loadDatabases() throws JAXBException, IOException{
        
        //If you want the end user to select the database name, 
        //you can code a request to retrieve a list of databases
        GetAvailableREDatabasesRequest req = new GetAvailableREDatabasesRequest();

        //IMPORTANT:  For hosted, You must pass a valid hostedSiteInfoID to 
        //GetAvailableREDatabases to retrieve the database list from 
        //SiteManager. If you dont, you will get the following error message:
        //       Server was unable to process request. ---> 
        //       You must pass a valid siteInfoID to GetAvailableDatabases if 
        //       the virtual directory is configured 
        // HostedSiteInfoID is ignored in hon hosted scenarios. 
        req.hostedSiteInfoID = "9a731bb7-0e50-48e3-b8c3-e03e16a5ac15";

        //Issue the request. Retrieve the reply.
        //Populate a combo box using the reply.
        //to retrieve the database list from SiteManager.
        GetAvailableREDatabasesReply reply = new GetAvailableREDatabasesReply();
        reply =
        _appFxWebService.getAppFxWebServiceSoap12().getAvailableREDatabases(req);

        //Create a list of Strings to contain database names.
        List<String> dbList = reply.getDatabases().getDb();
        for (String item : dbList){jComboBox_cbo_Databases.addItem(item);}; 
    }
    
    public void loadEvents() throws JAXBException, IOException{
        //You need 5 key pieces of information when consuming a feature.
        //User Name
        //Password
        //AppFxWebService.asmx URL
        //Database Key
        //System Record ID (Guid) or the Name of the feature that uniquely 
        //identifies the feature 
        //(i.e. datalist, dataform, searchlist, etc.)
        
        DataListLoadRequest req = new DataListLoadRequest();
        DataFormItem dfi = new DataFormItem();
        DataListLoadReply reply = new DataListLoadReply();
        
        req.clientAppInfo = _clientAppInfoHeader;
        
        //Provide the name of the feature as part of the request.  Use the 
        //metadata features like the Data List Search task to find the 
        //appropriate feature name.
        req.dataListName = "Event Calendar Event List";
        
        //As an alternative to the dataListName in the request, you could also 
        //use the dataListID/System Record ID. Provide the system record id of 
        //the feature.
        //req.dataListID = "cf479f2c-5657-42ca-8ed6-edde97c6a9ac";
        
        //If your data list has filters, you may need to provide a value for one
        //or several of the form fields which serve as the parameters for the 
        //datalist's filter. Try out the feature's filter within the application
        //to get a feel for each of the data list's parameters
        
        //Tip:  See the <Parameters> tag within the datalistspec's XML to view 
        //the FormField tags that declare the parameters for the data list. Or
        //see the Filters tab on the data list metadata page.   
                
        //DataFormItem is passed to the request.
        req.parameters = dfi;
        
        //Max rows acts as a governor to limit the amount of rows retrieved by 
        //the datalist.
        req.maxRows = 500;
        
        //If you plan on inspecting the metadata values that originated from 
        //DataListSpec xml doc, such as the FieldID or the IsHidden attributes 
        //of the OutputField element, then set includeMetaData to true
        req.includeMetaData = true;
        
        //Make the request.
        reply = _appFxWebService.getAppFxWebServiceSoap12().dataListLoad(req);
        
        //Add columns to the table for Events.
        tableModel.setColumnCount(0);
        for (int i = 0; i < 9; i++){
            tableModel.addColumn
(reply.metaData.outputDefinition.outputFields.getOutputField().get(i).caption);
        }
        
        //Add rows to the table for Events.
        tableModel.setRowCount(0);
        for (int i = 0; i < reply.totalRowsInReply; i++){
            tableModel.addRow(reply.rows.r.get(i).values.v.toArray());
        }              
    }

    public void loadExpenses(String eventID) throws JAXBException, IOException{
        DataListLoadRequest req = new DataListLoadRequest();
        DataListLoadReply reply = new DataListLoadReply();

        req.clientAppInfo = _clientAppInfoHeader;
        
        //Provide the name of the feature as part of the request.  Use the 
        //metadata features like the Data List Search task to find the 
        //appropriate feature name. Blackbaud Professional Services will need to
        //permission the API developer with rights to the feature metadata 
        //features.
        req.dataListName = "Event Expense List";
        
        //A data list may require a context value. Think of a context value as a
        //"parent id". In the example below we are pulling the expenses for an 
        //event. Therefore, the EventID would be the parent id.  

        //Context is optional for a data list.  A data list may not need a 
        //context value. These types of data lists are termed "top level data 
        //lists".  The "Event Calendar Event List" is an example of a top level 
        //data list.
        //To determine whether a data list requires a context value, 
        //look at for a <Context> XML element within the XML for the 
        //datalistspec. Alternatively, you could look to see if a value exists 
        //for the 'Context record type' in the summary section of the meta data 
        //page for the datalist.
        req.contextRecordID = eventID;
        
        //As an alternative to the dataListName in the request, you could also 
        //use the dataListID.
        //Provide the system record id of the feature.
        //req.dataListID = "a62332d9-3f64-4b44-8b66-cfedfc747587";

        //Max rows acts as a governor to limit the amount of rows retrieved by 
        //the datalist
        req.maxRows = 500;

        //If you plan on inspecting the metadata values that originated from 
        //DataListSpec XML doc, such as the FieldID or the IsHidden attributes 
        //of the OutputField element, then set includeMetaData to True
        req.includeMetaData = true;
        
        //The API utilizes a Request-Response pattern. The pattern consists of 
        //request-response pairs. An operation, such as dataListLoad, is called 
        //with the request.  The request is passed to the operation. A reply is 
        //received. Each request and reply type is tailored to the operation.
        //So, the dataListLoad operation will requires DataListLoadRequest and a
        //DataListLoadReply. Since we need to 'load' a datalist up with data we 
        //will call the dataListLoad operation. Following the Request-Response 
        //pattern, we package up a request (DataListLoadRequest), pass the 
        //request variable to the dataListLoad operation and receive a response 
        //(DataListLoadReply)

        reply = _appFxWebService.getAppFxWebServiceSoap12().dataListLoad(req);
                
        //Add columns to the table for Event Expenses.
        tableModelEventExpense.setColumnCount(0);
        for (int i = 0; i < 10; i++){
            tableModelEventExpense.addColumn
(reply.metaData.outputDefinition.outputFields.getOutputField().get(i).caption);
        }
        
        //Add rows to the table for Event Expenses.
        tableModelEventExpense.setRowCount(0);
        if (reply.totalRowsInReply != null) {
            for (int i = 0; i < reply.totalRowsInReply; i++){
tableModelEventExpense.addRow(reply.rows.r.get(i).values.v.toArray());
            }
        }
    }

    /** Creates new form Form1JFrame */
    public Form1JFrame() throws JAXBException, IOException {

        initComponents();
        loadDatabases();
        _clientAppInfoHeader.reDatabaseToUse = "BBInfinity";
        loadEvents();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jComboBox_cbo_Databases = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jButtonGetEvents = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jButtonAddExpense = new javax.swing.JButton();
        jButtonEditExpense = new javax.swing.JButton();
        jButtonDeleteExpense = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableEvents = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableEventExpense = new javax.swing.JTable();
        jButtonLoadExpenses = new javax.swing.JButton();

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable2);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jLabel1.setText("Select Database");

        jComboBox_cbo_Databases.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox_cbo_DatabasesActionPerformed(evt);
            }
        });

        jLabel2.setText("Select Event to Display Expenses");

        jButtonGetEvents.setText("Get Events");
        jButtonGetEvents.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGetEventsActionPerformed(evt);
            }
        });

        jLabel3.setText("Expenses for");

        jButtonAddExpense.setText("Add Expense");
        jButtonAddExpense.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedAddExpense(evt);
            }
        });
        jButtonAddExpense.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddExpenseActionPerformed(evt);
            }
        });

        jButtonEditExpense.setText("Edit Expense");
        jButtonEditExpense.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedEditExpense(evt);
            }
        });
        jButtonEditExpense.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditExpenseActionPerformed(evt);
            }
        });

        jButtonDeleteExpense.setText("Delete Expense");
        jButtonDeleteExpense.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedDeleteExpense(evt);
            }
        });
        jButtonDeleteExpense.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeleteExpenseActionPerformed(evt);
            }
        });

        jTableEvents.setModel(tableModel);
        jTableEvents.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane3.setViewportView(jTableEvents);
        //SelectionListener listener = new SelectionListener(jTableEvents);
        //jTableEvents.getSelectionModel().addListSelectionListener(listener);
        //jTableEvents.getColumnModel().getSelectionModel()
        //    .addListSelectionListener(listener);

        jTableEventExpense.setModel(tableModelEventExpense);
        jTableEventExpense.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(jTableEventExpense);

        jButtonLoadExpenses.setText("Load Expenses");
        jButtonLoadExpenses.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mouseClickedLoadExpenses(evt);
            }
        });
        jButtonLoadExpenses.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLoadExpensesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButtonLoadExpenses)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonAddExpense)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonEditExpense)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonDeleteExpense))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 858, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 614, Short.MAX_VALUE)
                        .addComponent(jButtonGetEvents))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox_cbo_Databases, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel3)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 858, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jComboBox_cbo_Databases, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel2))
                    .addComponent(jButtonGetEvents))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonDeleteExpense)
                    .addComponent(jButtonEditExpense)
                    .addComponent(jButtonAddExpense)
                    .addComponent(jButtonLoadExpenses))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

private void jButtonGetEventsActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        try {
            //When the user clicks Get Events, get the events rows and populate
            //the table - loadEvents().
            loadEvents();
        } catch (JAXBException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}                                                

private void jComboBox_cbo_DatabasesActionPerformed(java.awt.event.ActionEvent evt) {                                                        

    databaseToUse = jComboBox_cbo_Databases.getSelectedItem().toString();
}                                                       

private void mouseClickedLoadExpenses(java.awt.event.MouseEvent evt) {                                          
    try {
        //When the user clicks Load Expenses, get the expenses rows based on the
        //selected event and populate the table - loadExpenses().
            loadExpenses(jTableEvents.getValueAt(jTableEvents.getSelectedRow(), 0).toString());
    } catch (JAXBException ex) {
        Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
}                                         

private void mouseClickedAddExpense(java.awt.event.MouseEvent evt) {                                        
        try {
            //When the user clicks Add Expense, bring up the form to add an
            //add an expense to the selected event - addExpense().
            addExpense(jTableEvents.getValueAt
                    (jTableEvents.getSelectedRow(), 0).toString(),
                     jTableEvents.getValueAt
                        (jTableEvents.getSelectedRow(), 1).toString());
        } catch (JAXBException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}                                       

private void jButtonAddExpenseActionPerformed(java.awt.event.ActionEvent evt) {                                                  
// TODO add your handling code here:
}                                                 

private void jButtonEditExpenseActionPerformed(java.awt.event.ActionEvent evt) {                                                   
// TODO add your handling code here:
}                                                  

private void mouseClickedEditExpense(java.awt.event.MouseEvent evt) {                                         
        try {
            //When the user clicks Edit Expense, bring up the form to edit an
            //expense based on the selected expense - editExpense().
            editExpense(jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 0).toString());
        } catch (JAXBException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}                                        

private void jButtonLoadExpensesActionPerformed(java.awt.event.ActionEvent evt) {                                                    
// TODO add your handling code here:
}                                                   

private void jButtonDeleteExpenseActionPerformed(java.awt.event.ActionEvent evt) {                                                     
// TODO add your handling code here:
}                                                    

private void mouseClickedDeleteExpense(java.awt.event.MouseEvent evt) {                                           
        try {
            //When the user clicks Delete Expense, perform the record operation
            //to deleted the selected expense - deleteExpense().
            deleteExpense(jTableEventExpense.getValueAt(jTableEventExpense.getSelectedRow(), 0).toString());
        } catch (JAXBException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    
}                                          

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Form1JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Form1JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Form1JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Form1JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                try {
                    new Form1JFrame().setVisible(true);
                } catch (JAXBException ex) {
                    Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(Form1JFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
                
            }
            
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButtonAddExpense;
    private javax.swing.JButton jButtonDeleteExpense;
    private javax.swing.JButton jButtonEditExpense;
    private javax.swing.JButton jButtonGetEvents;
    private javax.swing.JButton jButtonLoadExpenses;
    private javax.swing.JComboBox jComboBox_cbo_Databases;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTableEventExpense;
    private javax.swing.JTable jTableEvents;
    // End of variables declaration                   
}