解决方案 »

  1.   

          Display display = new Display();
          Shell shell = new Shell(display);
          shell.setText("Main Window");
          shell.setLayout(new FillLayout());
          shell.setSize(500, 400);
    Button openButton = new Button(shell, SWT.PUSH);
    openButton.setLocation(2, 5);
    openButton.setSize(50, 20);
    openButton.setText("打开图片资源");
    openButton.addSelectionListener(new SelectionListener() { @Override
    public void widgetSelected(SelectionEvent e) { 打开对话框:
         FileDialog picFileDlg = new FileDialog(shell,SWT.OPEN);     picFileDlg.setFilterExtensions(new String[]{"*.jpg","*.png","*.gif"}); 
         picFileDlg.setFilterPath("D:/pic"); 
         picFileDlg.setText("请选择要打开的图片文件"); 
         String filePath = picFileDlg.open(); 

    }
      

  2.   

    我每次打开都需要new一个Shell?
      

  3.   

    我仅仅只是想用win风格的dialog而已