import java.util.ArrayList;
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class Login {
private JFrame theWind;
//private JPanel thePane;
private JLabel title;
private JButton ok;
//private JButton cancel;
private JTextField theText;
public Login(){
}
public void open(){
theWind = new JFrame("Login");
title = new JLabel("Please Enter Your Voter ID:");
ok = new JButton("OK");
//cancel = new JButton("Cancel");
theText = new JTextField();
theWind.setLayout(new BorderLayout());
theWind.add(title,BorderLayout.NORTH);
theWind.add(theText,BorderLayout.CENTER);
theWind.add(ok,BorderLayout.SOUTH);
theWind.pack();
theWind.setVisible(true);
}
}
I apologize this isn't the complete programs so some of the variables are not used yet. So when i click a button on another JFrame, this JFrame is supposed to open up. The problem occurs when it hits the line that sets the value for the Jframe. (the code below).
theWind = new JFrame("Login");
I get a run time error claiming a NullPointerException on that line. I checked to see if the the JFrame was declared, and it is. This is weird considering that my other JFrame runs fine, and I have all of the necessary java libraries imported. I have a JPanel and a JButton commented because I was trying to figure out if those things were messing up with the borderlayout but I don't think that's the problem. It's a relatively short code and I'm really stumped on this. I would be glad to receive any inputs/advice. thank you!