0
People,
I’m working on a vacation record.
The person places the initial date and a combo with the amount of days (10,15, 20 and 30) appears for her to complete it.
Until 30 days of holidays are launched for the employee the screen does not close.(Each iteration adds the amount of the previous until 30) But I wanted the amount of days available on Jcombobox to be changeable. For example I launched 20 days, jcombobox should give only the option of 10. I launched 15 days only option of 15 and releasing 10 days option of 10 and 20. However I cannot clean and re-fix values in the combo.
A Nullpointerexception error appears
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());
}
The 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)
How can I clear the predefined values and put new ones?
Welcome(a). Could you create an example that is reproducible? - [mcve]
– Renan Gomes