Would anyone know to tell me some Listener for when I select an item in JComboBox it gives me a warning for example. Remembering that when I open my component (JFrame) I hide items in there by the bank so I can not fall into the Listener.
Lets go there explaining my project better
The "..." button opens the mode register window, every time I register a mode I update the combo box "mode" which currently has the "dance" record every time I choose a mode in my combobox it will open a new window to register the monthly fee. So how do I load my combobox by the time I open my application without activating the listener and how do I update the combobox without activating the listener? I want the listener to only be activated when the user selects an item from the list, but by what seems the command "combobox.addItem (" Test "); activates the listener at the time of updating. Any suggestions?
MethodusedtoupdatetheComboboxwhenIregisteramodeorwhenIjustopenmysystem.
publicvoidsetModalidade(){try{this.cboModalidade.removeAllItems();this.listaModalidade=newArrayList<Modalidade>(newModalidadeDAO().listaTodos());inti=0;for(Modalidademodalidade:listaModalidade){this.cboModalidade.addItem(modalidade.getTituloModalidade());if(this.modalidade.getTituloModalidade().equalsIgnoreCase(modalidade.getTituloModalidade())){this.cboModalidade.setSelectedIndex(i);}i++;}}catch(SQLExceptione){e.printStackTrace();}}
ThisisthelistenerIuseorhavealreadytried.
JComboboxcombobox=newJCombobox<>();combobox.addActionListener(this);//<--játenteiessecombobox.addItemListener(this);//<--Estouusandoessemasafunção"combobox.addItem("Teste"); que utilizou para atualizar meu combobox ativa o ActionListener e o ItemListener