简体   繁体   中英

Is there a Eclipse plugin for a File Browser Dialog button?

I have searched the web for quite a while now, and have not come across a simple solution for making a button, which opens a file browsing dialog in an Eclipse program. I am using WindowBuilder at the moment, and it seems odd to me, that one has to do so much to add a simple "Browse..." button to their GUI.

I hope someone can help me on this matter, thanks!

I use this code:

 private Button browse;
   browse = new Button(outerGroup, SWT.PUSH);
        browse.setText("Browse ...");
        browse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,1,0));
        browse.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NULL);
                String path = dialog.open();
                if (path != null) {
                    //do stuff with path
                }
            }

        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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