Boa noite… tenho uma combobox (e nela contem: nenhum, data, tecnico, valor)
como faço pra que a medida que o usuario for mudando o item da combobox,
algumas labels fosse desabilitada. Ex: o usuario escolheu item data da combobox,
ae automaticamente ele desabilitasse as labels tecnico e valor…
ja tentei usar o mouserelease e o mouse pressed… mas funciona so pela metade…kkk
Já consultou a documentação do JComboBox?
Utilize um ItemListener.
muito obrigado, pesquisei aqui no forum sobre itemlistener e achei uma dica do thingol e funfou perfeitamente…
private void combofiltroMouseClicked(java.awt.event.MouseEvent evt) {
combofiltro.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent ie) {
if(ie.getStateChange()==ItemEvent.SELECTED){
if(combofiltro.getSelectedItem().toString().equalsIgnoreCase("Técnico")){
txtformatdata1.setEnabled(false);
txtformatdata2.setEnabled(false);
txtformatvalor1.setEnabled(false);
txtformatvalor2.setEnabled(false);
txttecnico.setEnabled(true);
}
if(combofiltro.getSelectedItem().toString().equalsIgnoreCase("valor")){
txtformatdata1.setEnabled(false);
txtformatdata2.setEnabled(false);
txttecnico.setEnabled(false);
txtformatvalor1.setEnabled(true);
txtformatvalor2.setEnabled(true);
}
}
}
});
}