我制作了这个JavaFX应用程序,每次在未定义的时间内使用它都会崩溃,它给出的唯一错误是这个错误:
java[1133:134799] unrecognized type is 4294967295
java[1133:134799] *** Assertion failure in -[NSEvent _initWithCGEvent:eventRef:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671.10.106/AppKit.subproj/NSEvent.m:1969
java[1133:134799] unrecognized type is 4294967295
java[1133:134799] *** Assertion failure in -[NSEvent _initWithCGEvent:eventRef:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671.10.106/AppKit.subproj/NSEvent.m:1969
java[1133:134799] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: _type > 0 && _type <= kCGSLastEventType'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff37e04e65 __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff63e5b720 objc_exception_throw + 48
2 CoreFoundation 0x00007fff37e1fab2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff3a1c3d1d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 AppKit 0x00007fff352ac029 -[NSEvent _initWithCGEvent:eventRef:] + 3272
5 AppKit 0x00007fff355ff74c +[NSEvent eventWithCGEvent:] + 120
6 libglass.dylib 0x000000011c0086fb listenTouchEvents + 59
7 SkyLight 0x00007fff5df1141e _ZL19processEventTapDataPvjjjPhj + 148
8 SkyLight 0x00007fff5de0fc9e _XPostEventTapData + 278
9 SkyLight 0x00007fff5df1132c _ZL22eventTapMessageHandlerP12__CFMachPortPvlS1_ + 132
10 CoreFoundation 0x00007fff37d657cf __CFMachPortPerform + 282
11 CoreFoundation 0x00007fff37d656a9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
12 CoreFoundation 0x00007fff37d65607 __CFRunLoopDoSource1 + 527
13 CoreFoundation 0x00007fff37d4d689 __CFRunLoopRun + 2574
14 CoreFoundation 0x00007fff37d4ca28 CFRunLoopRunSpecific + 463
15 HIToolbox 0x00007fff36fe5b35 RunCurrentEventLoopInMode + 293
16 HIToolbox 0x00007fff36fe5774 ReceiveNextEventCommon + 371
17 HIToolbox 0x00007fff36fe55e8 _BlockUntilNextEventMatchingListInModeWithFilter + 64
18 AppKit 0x00007fff352a1eb7 _DPSNextEvent + 997
19 AppKit 0x00007fff352a0c56 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
20 libglass.dylib 0x000000011bff646c +[GlassApplication enterNestedEventLoopWithEnv:] + 172
21 libglass.dylib 0x000000011bff6eaa Java_com_sun_glass_ui_mac_MacApplication__1enterNestedEventLoopImpl + 74
22 ??? 0x0000000106546667 0x0 + 4401161831
23 ??? 0x0000000106536040 0x0 + 4401094720
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Java Result: 134
我在Windows和Linux上尝试了相同的应用程序,并且运行良好,因此我不知道在MacO上是否需要在代码中添加或更改某些内容。这是我的应用程序的主要功能:
public class MailBox extends Application {
@Override
public void start(Stage stage) throws Exception {
FXMLLoader listLoader = new FXMLLoader(getClass().getResource("lista.fxml"));
FXMLLoader menuLoader = new FXMLLoader(getClass().getResource("menubar.fxml"));
FXMLLoader textareaLoader = new FXMLLoader(getClass().getResource("textarea.fxml"));
FXMLLoader fieldLoader = new FXMLLoader(getClass().getResource("textfield.fxml"));
FXMLLoader buttonLoader = new FXMLLoader(getClass().getResource("button.fxml"));
AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());
ListController listController = listLoader.getController();
MenuBarController menuController = menuLoader.getController();
TextAreaController textareaController = textareaLoader.getController();
TextFieldController fieldController = fieldLoader.getController();
ButtonController buttonController = buttonLoader.getController();
DataModel model = new DataModel();
listController.initModel(model);
menuController.initModel(model);
textareaController.initModel(model);
fieldController.initModel(model);
buttonController.initModel(model);
Scene scene = new Scene(root, 603, 403);
stage.setScene(scene);
stage.show();
}
这是我的Panel控制器的一部分,我在其中声明了另一个阶段:
public class PanelController {
@FXML
private TextField dest;
@FXML
private TextField obj;
@FXML
private TextArea testo;
@FXML
private Button invia;
private DataModel model;
public void initModel(DataModel model) {
if (this.model != null) {
throw new IllegalStateException("Model can only be initialized once");
}
this.model = model;
}
public void initRispondi(DataModel model) {
dest.setText(model.currentEmailProperty().getValue().getMittente());
dest.setDisable(true);
}
public void initReplyAll(DataModel model) {
final ObservableList<Email> elenco = model.getEmailList();
String s = "";
for (Email mail : elenco) {
s+=""+mail.MittenteProperty().getValue()+"; ";
}
dest.setText(s);
dest.setDisable(true);
}
public void initForward(DataModel model) {
obj.setText(model.currentEmailProperty().getValue().getOggetto());
testo.setText(model.currentEmailProperty().getValue().getTesto());
}
@FXML
public void scrivi() throws IOException {
String[] da_inv = new String[4];
da_inv[0] = dest.getText();
da_inv[1] = model.getAccountName();
da_inv[2] = obj.getText();
da_inv[3] = testo.getText();
boolean ok = true;
for (int i=0; i<4 && ok; i++) {
if (da_inv[i].length()<1)
ok = false;
}
if (!ok)
new Alert(Alert.AlertType.ERROR, "Compila tutti i campi!").showAndWait();
else {
model.writeMail(da_inv);
Window stage = dest.getScene().getWindow();
stage.hide();
}
}
}