Acquisition of data by JTable

0

I'm trying to get JButtonGuardar(panelInserir) to pass data entered by the user (local time text) from JPanelInserir to JPanelEventos (where is JTable)

At the moment, I am not succeeding, if you have any suggestions, I will leave the following code where the problem is occurring:

  

error: Exception in thread "AWT-EventQueue-0"   java.lang.NullPointerException at   net.ruimendes.Tentative $ 8.actionPerformed (Attempt.java:417)

Code where the error is occurring:

JButton btnGuardar = new JButton("Guardar");
btnGuardar.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        try {
            double hora = Double.parseDouble(textHoraInicio.getText());
            String texto = textTexto.getText();
            String local = textLocal.getText();
            Agendado agen = new Agendado(hora, texto, local);
            eventoAtual.adicionaAgendado(agen);
            textHoraInicio.setText(String.format("%.2f", eventoAtual.getHora()));
            textHoraInicio.setText("");
            textTexto.setText("");
            textLocal.setText("");
        } catch (NumberFormatException e1) {

            e1.printStackTrace();
        } catch (AgendadoNuloException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }


    }
});

The full code is in this link

    
asked by anonymous 21.04.2016 / 02:11

1 answer

1

The problem occurs because you declared the variable eventoAtual at the beginning of the class, but did not start it and assign no object to it. So when you call it in this action, the variable is null .

Not to mention that you are initiating a local variable of the same name as your already-mentioned attribute (check the escolheNovoEvento method), perhaps this is why the variable is never started.

I've already answered about this type of problem in another answer , read the explanation, and review your code at search for this type of problem.

    
21.04.2016 / 16:09