Jag försöker göra en JButton för att ta bort en kund, men kunden finns kvar efter jag använt knappen i interfacet. Såhär ser koden ut i interfacet:
btnRemoveCustomer = new JButton("Ta bort kund");
btnRemoveCustomer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String cNumberFind = customerNbrTextField.getText(); {
String [] tmpCustomer = controller.findCustomer(cNumberFind);
if (tmpCustomer !=null) {
controller.removeCustomer(cNumberFind);
lblNewKund.setText("Kund borttagen");
} else {
lblNewKund.setText("Kund hittades inte")
och i min controller:
public void removeCustomer(String CNumber) { //DELETE CUSTOMER
Customer customer = customerRegister.getCustomer(CNumber);
if (customer != null) customerRegister.removeCustomer(customer); }
denna finns i klassen kundregister
public boolean removeCustomer(Customer customer) {
return customers.remove(customer);
nån som kan se nåt fel i koden?