1
Before asking this question, I searched the forum and in several places but could not solve...
I have a combobox that already carries the names of customers, then I wanted to select the customer, and on a button ok
search for this client. However, when comparing names, it falls into the message that it was not found.
private void btnBuscaClientesActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel model = (DefaultTableModel) jTableClientes.getModel();
String nomeCliente = comboClientes.getSelectedItem().toString();
ConsultasDAO consulta = new ConsultasDAO();
List<Cliente> clientes = null;
try {
clientes = consulta.getClientes();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Erro sql");
//Logger.getLogger(TelaRelatorioGUI.class.getName()).log(Level.SEVERE, null, ex);
}
for (Cliente nomeClienteAtual : clientes) {
if ((nomeCliente.toLowerCase()) == (nomeClienteAtual.getnome().toString().toLowerCase())) {
model.addRow(new Object[]{nomeClienteAtual.getnome().toLowerCase(), nomeClienteAtual.gettelefone(), nomeClienteAtual.getrua(), nomeClienteAtual.getcomplemento()});
} else {
JOptionPane.showMessageDialog(null, "Cliente não encontrado");
}
}
}
Please provide a [mcve] so that it is possible to execute and test the code, and propose a solution.
– user28595