これで数時間は苦労しています。私はいくつかのswtコードを実行しようとしていますが、このIllegalArgumentExceptionが発生していると私はなぜかの手がかりを持っていません。SWT java.lang.IllegalArgumentException:引数をnullにすることはできません。
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;
}
私が最初getLogFileImportLocationを呼び出す順序を変更した後、メッセージボックスを表示した場合のライン
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)
を与えますこの問題はMessageBoxの初期化で発生します。
私はswtで非常にnoobだから私はここで何が起こっているか分からない。アドバイスできますか?
多くのthx。
Thx、それでした! :) – HugoFS