Pessoas,
Estou trabalhando em um cadastro de férias.
A pessoa coloca a data inicial e um combo com a quantidade de dias (10,15, 20 e 30)aparece para que ela o complete.
Enquanto não forem lançados 30 dias de ferias para o funcionario a tela não fecha.(A cada iteração soma-se a quantidade da anterior até dar 30) Mas queria que a quantidade de dias disponiveis no JComboBox fosse alteravel. Por exemplo lancei 20 dias, o jcombobox deveria dar somente a opção de 10. Lancei 15 dias apenas a opção de 15 e lançando 10 dias a opção de 10 e 20. Contudo não consigo limpar e readicionar valores no combo.
Aparece um erro de NullPointerException
if (crt.getSomaQuantidadeFerias(rf.getText(), ex.getText()) < 30) {
int soma = 30 - crt.getSomaQuantidadeFerias(rf.getText(), ex.getText());
inicio_ferias.setText("");
qtd.setSelectedItem(null);
inicio_ferias.setText("");
termino_ferias.setText("");
tfmes.setText("");
try{
qtd.removeAllItems();
if(soma == 10){
qtd.addItem("10");
qtd.addItem("20");
}else if(soma == 15){
qtd.addItem("15");
}else if(soma == 20){
qtd.addItem("10");
}}catch(Exception e){
e.printStackTrace();
System.out.println(e.getMessage());
}
O printStackTrace()
java.lang.NullPointerException
at view.TelaFerias$4.actionPerformed(TelaFerias.java:439)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.setSelectedItem(Unknown Source)
at view.TelaFerias$2.actionPerformed(TelaFerias.java:385)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Como posso limpar os valores pré-definidos e colocar novos?