Я борюсь с этим уже несколько часов. Я пытаюсь запустить SWT-код, но происходит исключение IllegalArgumentException, и я понятия не имею, почему.
private void loadLogFromFile() {
MessageBox mbox = new MessageBox(Display.getCurrent().getActiveShell(),
SWT.YES | SWT.NO | SWT.ICON_QUESTION);
mbox.setText("Confirmation");
mbox.setMessage ("This operation will clear de current selected device and " +
"all logs currently being displayed. Do you wish to continue?");
final int mboxResult = mbox.open();
if (mboxResult != SWT.YES) {
return;
}
final String fName = getLogFileImportLocation();
if (fName == null) {
return;
}
}
getLogFileImportLocation код:
private String getLogFileImportLocation() {
FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
fd.setText("Load Log..");
fd.setFileName("log.txt");
if (mLogFileImportFolder == null) {
mLogFileImportFolder = System.getProperty("user.home");
}
fd.setFilterPath(mLogFileImportFolder);
fd.setFilterNames(new String[] {
"Text Files (*.txt)"
});
fd.setFilterExtensions(new String[] {
"*.txt"
});
String fName = fd.open();
if (fName != null) {
mLogFileImportFolder = fd.getFilterPath(); /* save path to restore on future calls */
}
return fName;
}
Линия
FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
Всегда дает
java.lang.IllegalArgumentException: Argument cannot be null
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Dialog.error(Unknown Source)
at org.eclipse.swt.widgets.Dialog.checkParent(Unknown Source)
at org.eclipse.swt.widgets.Dialog.<init>(Unknown Source)
at org.eclipse.swt.widgets.FileDialog.<init>(Unknown Source)
Если я сначала изменю порядок вызова getLogFileImportLocation и покажу MessageBox, проблема возникнет при инициализации MessageBox.
Я очень новичок в SWT, поэтому я понятия не имею, что здесь происходит. Вы можете посоветовать?
Многие, спасибо.