/** Initial method to populate the insuranceCompaniesTable */ public void loadTable() { Map<Integer, InsuranceCompany> data = model.getInsuranceCompanies(); tableData = new InsuranceCompanyTableModel(data); insuranceCompaniesTable.setModel(tableData); insuranceCompaniesTable.getColumnModel().getColumn(0).setMaxWidth(50); insuranceCompaniesTable .getSelectionModel() .setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Check if db is empty and proceed with selecting only if the table is populated if (insuranceCompaniesTable.getRowCount() > 0) { // Set selected company according to selected row on load selectRow(); int selectedCompanyId = Integer.valueOf( (String) insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0)); } }