public class checkUsernames extends JFrame {
private static JTextArea textArea1;
private static JButton button1;
private static JScrollPane scrollPane1;
private static JTextField textField1;
private static JPasswordField passwordField1;
private static JLabel label3;
private static JButton button2;
private static JLabel label1;
private static JLabel label2;
public checkUsernames() {
initComponents();
}
public static void main(String[] args) throws IOException {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Nimbus isn't available");
}
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
checkUsernames GUI = new checkUsernames();
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.setVisible(true);
}
});
String username = textField1.toString();
String password = passwordField1.toString();
Exception in thread "main" java.lang.NullPointerException
checkUsernames
是唯一的班级。当我尝试运行应用程序时,程序会进一步执行(在没有字符串用户名和字符串密码的情况下继续执行)而不等待输入。我怎样才能解决这个问题?