0

I'm trying to create a new UI for database project. However, I keep getting a nullpointerexception at creating a new GUI object, and when adding content. Here is my code:

class DatabaseGUI extends JFrame implements ActionListener {

JTextField input;
JTextArea restult;
JButton loadButton;
JButton saveButton;



public static void main(String[] args){

    DatabaseGUI databaseGUI = new DatabaseGUI();
    databaseGUI.setVisible(true);

}

DatabaseGUI(){

    this.setTitle("Emplyoee Database");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container content = getContentPane();
    content.setLayout(new FlowLayout());

    content.add(saveButton);


}
Ameer Akashe
  • 63
  • 1
  • 1
  • 4
  • The heuristic for NullPointerExceptions is almost always the same: You should critically read your exception's stacktrace to find the line of code at fault, the line that throws the exception, and then inspect that line carefully, find out which variable is null, and then trace back into your code to see why. You will run into these again and again, trust me. – Hovercraft Full Of Eels Nov 13 '16 at 21:26
  • Hint: again the offending line will show you the problem -- you're trying to add something to the GUI that is null... – Hovercraft Full Of Eels Nov 13 '16 at 21:27

0 Answers0