I'm having trouble with calling a get method from one class and implementing it in a seperate actionlistner class. Here is the code for my get method which gets the text from a JTextField.
public String getTitleTextField() {
return this.TitleTextField.getText();
}
The button that calls the listner class is below:
this.AddButton = new JButton("Add");
AddButton.setBounds(20, 161, 89, 23);
AddButton.addActionListener(new Listener());
add(AddButton);
Here is the code for my listner class: `
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Listener implements ActionListener{
FilmPanel view;
SaveData save;
Object[] row = new Object[1];
public void actionPerformed(ActionEvent arg0) {
row[0] = view.getTitleTextField();
view.model.addRow(row);
try {
save.saveTable();
} catch (Exception e) {
e.printStackTrace();
}
};
}
The error comes up as
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at assignment.listener.actionPerformed(listener.java:13)
which points to this row[0] = view.getTitleTextField();
Thanks for any help :)
EDIT:
Trying to figure out what's wrong its not a NULL exception