java编程用到swt,打开文件夹的方法的参数是啥

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java编程用到swt,打开文件夹的方法的参数是啥相关的知识,希望对你有一定的参考价值。

public class server extends Shell

private List list;
/**
* Launch the application
* @param args
*/
public static void main(String args[])
try
Display display = Display.getDefault();
server shell = new server(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();

catch (Exception e)
e.printStackTrace();



/**
* Create the shell
* @param display
* @param style
*/
public server(Display display, int style)
super(display, style);
createContents();
setLayout(new FillLayout());


/**
* Create contents of the window
*/
protected void createContents()
setText("SWT Application");
setSize(500, 375);

final Composite composite = new Composite(this, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
composite.setLayout(gridLayout);

list = new List(composite, SWT.BORDER);
final GridData gd_list = new GridData(SWT.FILL, SWT.BOTTOM, false, false, 3, 1);
gd_list.heightHint = 227;
gd_list.widthHint = 396;
list.setLayoutData(gd_list);

final Button open = new Button(composite, SWT.NONE);
open.addSelectionListener(new SelectionAdapter()
public void widgetSelected(final SelectionEvent e)
//打开文件夹,这里的参数是什么???
FileDialog fileDialog = new FileDialog();

);
final GridData gd_open = new GridData(SWT.LEFT, SWT.CENTER, false, true);
gd_open.widthHint = 152;
open.setLayoutData(gd_open);
open.setText("打开");

final Button submit = new Button(composite, SWT.NONE);
final GridData gd_submit = new GridData(SWT.FILL, SWT.CENTER, false, true);
gd_submit.widthHint = 169;
submit.setLayoutData(gd_submit);
submit.setText("确定");

final Button exit = new Button(composite, SWT.NONE);
final GridData gd_exit = new GridData(SWT.LEFT, SWT.CENTER, false, true);
gd_exit.widthHint = 151;
exit.setLayoutData(gd_exit);
exit.setText("退出");
//

@Override
protected void checkSubclass()
// Disable the check that prevents subclassing of SWT components


我知道是父类,但是我是初学者,不知道在这个程序里应该写什么,参数到底是什么啊?晕

声明一个Dialog或者Frame这个是JAVA的内置对象。用来确定你要加载的文件!!!

参考技术A 用DirectoryDialog。会跳出那种专门用来选文件夹的对话框(用树形结构显示文件夹,看不到文件的那种)。
DirectoryDialog dialog = new DirectoryDialog(Shell);
而且有setFilterPath(String )方法来限制显示的文件夹。

以上是关于java编程用到swt,打开文件夹的方法的参数是啥的主要内容,如果未能解决你的问题,请参考以下文章

java中awt与swt的区别是啥?

swt是啥

swt是啥意思

java用swt 如何建立选择文件夹路径的对话框?

jface中文是啥意思

Java SWT编程基础