【发布时间】:2013-08-01 14:08:58
【问题描述】:
我想在我的应用程序中做一个按钮,让我进入系统中的环境变量列表 像下面的例子进入文件系统
b = new Button(dialog, SWT.PUSH);
b.setText("Browse file system");
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog fileDialog = new DirectoryDialog(parent);
fileDialog.setFilterPath(pathText.getText());
String file = fileDialog.open();
if (file != null) {
File workspace = ResourcesPlugin.getWorkspace().getRoot()
.getLocation().toFile().getAbsoluteFile();
String workspacePath = workspace.toString();
if (file.contains(workspacePath))
file = file.replace(workspacePath, "$WORKSPACE")
.replace("\\", "/");
pathText.setText(file);
}
super.widgetSelected(e);
}
});
谁能帮帮我??
【问题讨论】:
标签: java eclipse environment-variables