-1

my code and save button is this. I want to pass to another frames' jTable. but i get errors. can you figure it out?

It says:

Multiple markers at this line - DefaultTableModel cannot be resolved to a type - The static field Reservations.booked should be accessed in a static way

I already set it into public static but no changes occured.

btnConfirm = new JButton("Confirm");
    btnConfirm.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Reservations re = new Reservations();
            re.setVisible(true);
            re.textField.setText(txtEvent.getText());
            String d1 = txtEvent.getText();
            String d2 = textReg.getText();
            Object[] row = {d1, d2};
            re.DefaultTableModel des = (DefaultTableModel)re.booked.getModel();
            des.addRow(row);
        }
  • What error messages are you getting? Please add them to your question. – Petr Hejda Jun 19 '16 at 09:05
  • Multiple markers at this line - DefaultTableModel cannot be resolved to a type - The static field Reservations.booked should be accessed in a static way – Ghaddul Basar Jun 19 '16 at 09:09
  • 1) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) It seems like one of the frames should instead be a dialog. 2) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Jun 19 '16 at 11:39
  • *"The static field Reservations.booked should be accessed in a static way"* On a more general note, GUI components & models should mostly ***not*** be declared `static`. It is a sign of going about fixing a problem (access to an attribute) the wrong way. – Andrew Thompson Jun 19 '16 at 11:42

1 Answers1

0

Reservations re is not static . It should also declares as static variable if you want to use it as a static context