我一直在经历这个奇怪的问题。我正在创建一个具有登录屏幕的JavaFX应用程序。
问题是每当我输入用户名和密码后按Enter键,我会遇到以下致命错误。如果我使用“登录”按钮,它可以正常工作。
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007efc4bf78948, pid=7213, tid=139620596950784
#
# JRE version: Java(TM) SE Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.91-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x6cf948] jni_invoke_nonstatic(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x38
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
完整错误日志here。
以下是用于检测ENTER键的用户名字段和密码字段的动作侦听器:
fieldUsername.setOnKeyPressed((KeyEvent event) -> {
if (event.getCode() == KeyCode.ENTER) {
KeyEvent.fireEvent(buttonLogin, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, true, true, true, true, true, true, true, true, true, true, null));
}
});
fieldPassword.setOnKeyPressed((KeyEvent event) -> {
if (event.getCode() == KeyCode.ENTER) {
KeyEvent.fireEvent(buttonLogin, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, true, true, true, true, true, true, true, true, true, true, null));
}
});
每当我按下ENTER键时,我都会触发登录按钮。
以下是buttonLogin
的动作监听器:
buttonLogin.setOnMouseClicked((MouseEvent event) -> {
CheckLoginAndPin c1 = new CheckLoginAndPin();
if (!fieldUsername.getText().isEmpty() && !fieldPassword.getText().isEmpty()) {
if (c1.checkUsername(fieldUsername.getText())) {
if (c1.login(fieldUsername.getText(), fieldPassword.getText())) {
ArrayList<String> arrayListGetUserDetails = c1.getPriviledge(fieldUsername.getText());
stageLogin.close();
MainFrame mainFrame = new MainFrame(arrayListGetUserDetails.get(0), arrayListGetUserDetails.get(1), arrayListGetUserDetails.get(2), fieldUsername.getText());
} else {
PopupErrorMessage popupErrorMessage = new PopupErrorMessage(stageLogin, "Password incorrect", fieldPassword, 100, 60);
}
} else {
PopupErrorMessage popupErrorMessage = new PopupErrorMessage(stageLogin, "User name incorrect", fieldUsername, 100, 60);
}
} else {
if (fieldUsername.getText().isEmpty() && !fieldPassword.getText().isEmpty()) {
PopupErrorMessage popupErrorMessage = new PopupErrorMessage(stageLogin, "User name can not be empty", fieldUsername, 100, 60);
} else if (fieldPassword.getText().isEmpty() && !fieldUsername.getText().isEmpty()) {
PopupErrorMessage popupErrorMessage = new PopupErrorMessage(stageLogin, "Password can not be empty", fieldPassword, 100, 60);
} else if (fieldUsername.getText().isEmpty() && fieldPassword.getText().isEmpty()) {
PopupErrorMessage popupErrorMessage = new PopupErrorMessage(stageLogin, "User name & password can not be empty", fieldUsername, 100, 60);
}
}
});
JDK - Oracle Java 8 Update 91
操作系统 - Ubuntu 16.04 LTS 64位
IDE - Netbeans IDE 8.0.2
我在这里做错了什么?