Before asking this question, I looked in the forum and in several places but I could not solve ...
I have a comboBox that already loads the names of the clients, there I wanted to select the client, and on a ok
button to fetch that client. However, when comparing names, it falls on 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");
}
}
}