JButton btnNewButton = new JButton("Confirm Addition");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- if (table.getRowCount()!=0) {
+ if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
HouseManagerInterface hm = new HouseManager();
RuralHouse rh = houses.get(table.getSelectedRow());
//TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.