简体   繁体   English

SWT Filedialog打开到主文件夹

[英]SWT Filedialog Open into home folder

I want to open a FileDialog window into the user home folder (ie /home/user or /Users/unsername) 我想打开FileDialog窗口进入用户主文件夹(即/ home / user或/ Users / unsername)

I read the user home folder, using System.getProperty: 我使用System.getProperty读取了用户主文件夹:

  String homefolder = System.getProperty(user.home);

And the variable containts the correct home folder. 并且该变量包含正确的主文件夹。 But when i set the filterpath in FileDialog, it opens (in linux) only the /home level not entering into the user home dir. 但是,当我在FileDialog中设置filterpath时,它在Linux中仅打开/ home级别,而没有输入用户主目录。

This is the source code: 这是源代码:

  FileDialog dialog = new FileDialog(shell); 
  dialog.setText("Choose a certificate");
  String platform = SWT.getPlatform();
  String homefolder = System.getProperty("user.home");
  dialog.setFilterPath(homefolder);

Any idea? 任何的想法? Here a screenshot: 这里的截图: swt FileDialog问题

Your code works perfectly with SWT 3.6.1. 您的代码与SWT 3.6.1完美配合。 There is a bug report here stating that this was a problem in SWT versions <= 3.3 and was fixed in 3.4. 这里有一个错误报告指出这是SWT版本<= 3.3中的问题,并已在3.4中修复。

So, the solution would be to install a never version (ideally the current version). 因此,解决方案将是安装一个Never版本(最好是当前版本)。

Since you mentioned that you use a Maven repository, there is one for SWT 3.8 here: 由于您提到使用Maven存储库,因此这里有一个SWT 3.8:

maven project: SWT 3.5 dependency: any official public repo? Maven项目:SWT 3.5依赖项:是否有任何官方的公共仓库?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM