FileDialog ウィンドウをユーザーのホーム フォルダー (つまり、/home/user または /Users/unsername) に開きたい
System.getProperty を使用して、ユーザーのホーム フォルダーを読み取ります。
String homefolder = System.getProperty(user.home);
また、変数には正しいホーム フォルダーが含まれています。しかし、FileDialog でフィルターパスを設定すると、(Linux では) ユーザーのホーム ディレクトリに入らない /home レベルのみが開きます。
これはソースコードです:
FileDialog dialog = new FileDialog(shell);
dialog.setText("Choose a certificate");
String platform = SWT.getPlatform();
String homefolder = System.getProperty("user.home");
dialog.setFilterPath(homefolder);
何か案が?ここにスクリーンショットがあります: