title: FileDialog and Composite
body: <p>I am trying to create a browse button with <code>FileDialog</code> and composite in Java SWT. (Composite because, I am use <code>CTabFolder</code> and <code>CTabItem</code>. I felt to add components to <code>CTabItem</code> composite is good enough)</p>
  
  <pre><code>import java.io.BufferedReader; 
  import java.io.File;
  import java.io.FileReader;
  import java.util.StringTokenizer;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.Button;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.FileDialog;
  import org.eclipse.swt.widgets.Group;
  import org.eclipse.swt.widgets.Label;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.swt.widgets.TabFolder;
  import org.eclipse.swt.widgets.TabItem;
  import org.eclipse.swt.widgets.Table;
  import org.eclipse.swt.widgets.TableColumn;
  import org.eclipse.swt.widgets.TableItem;
   import org.eclipse.swt.widgets.Text;
  import org.eclipse.swt.custom.CBanner;
  import org.eclipse.swt.events.SelectionAdapter;
  import org.eclipse.swt.events.SelectionEvent;
  import org.eclipse.swt.graphics.Point;
  import org.eclipse.swt.layout.FillLayout;
  import org.eclipse.wb.swt.SWTResourceManager;
  
  public class DemoShell extends Shell {
    protected Composite composite;
    private Text filename;
    private Table table;
    protected Shell shell;
  
  public static void main(String args[]) {
    try {
  Display display = Display.getDefault();
  DemoShell shell = new DemoShell(display);
  shell.open();
  shell.layout();
  while (!shell.isDisposed()) {
  if (!display.readAndDispatch()) {
      display.sleep();
  }
  }
  } catch (Exception e) {
  e.printStackTrace();
   }
  }
  
  private static boolean parseFile(Table table, String filename) { 
      try { 
            BufferedReader br = new BufferedReader( new FileReader(filename) ); 
            String line = ""; 
            StringTokenizer token = null, subtoken = null; 
  
            int tokenNum = 1; 
  
            while((line = br.readLine()) != null) { 
  
                //  lineNum++;                     
                // break comma separated file line by line
  
                  token = new StringTokenizer(line, ";"); 
                  String sno = null;
  
                  while(token.hasMoreTokens()) { 
                      subtoken = new StringTokenizer(token.nextToken().toString(), ",");
                      sno = "";
                      sno = Integer.toString(tokenNum);
                      TableItem item = new TableItem (table, SWT.NONE);
                      item.setText (0, sno );
                      item.setText (1, subtoken.nextToken());
                      item.setText (2, subtoken.nextToken());
                      item.setText (3, subtoken.nextToken());
                      item.setText (4, subtoken.nextToken());
                      item.setText (5, subtoken.nextToken());
                        tokenNum++; 
                        System.out.println("S.No # " + tokenNum + token.nextToken()); 
                  } 
  
                  tokenNum = 0; 
            } 
            br.close(); 
            return true; 
      } catch(Exception e) { 
            System.err.println("Parse Error: " + e.getMessage()); 
            return false; 
      } 
    }
  
  
  public void displayFiles(String[] files) {
        for (int i = 0; files != null &amp;&amp; i &lt; files.length; i++) {
            filename.setText(files[i]);
            filename.setEditable(false);
        }
      }
  /**
   * Create the shell.
   * @param display
   */
  public DemoShell(Display display) {
      super(display, SWT.SHELL_TRIM);
  
      TabFolder tabFolder = new TabFolder(this, SWT.NONE);
      tabFolder.setBounds(10, 10, 462, 268);
  
      TabItem re_item = new TabItem(tabFolder, SWT.NONE);
      re_item.setText("Road Network");
  
      TabItem ttable_item = new TabItem(tabFolder, SWT.NONE);
      ttable_item.setText("Time Table");
  
      createContents_tt(tabFolder, ttable_item );
  }
  
  /**
   * Create contents of the shell.
   */
  protected void createContents_tt(TabFolder tabFolder, TabItem ttable_item) {
      setText("SWT Application");
      setSize(530, 326);
  
  
      //Table declaration
      table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);
      table.setBounds(10, 153, 450, 107);
      table.setHeaderVisible(true);
      table.setLinesVisible(true);
      String[] titles = {"S.No", "Route", "Transport #", "Cross Point", "Start Time", "End Time"};
      for (int i=0; i&lt;titles.length; i++) {
          TableColumn column = new TableColumn (table, SWT.NONE);
          column.setText (titles [i]);
      }
      for (int i=0; i&lt;titles.length; i++) {
          table.getColumn (i).pack ();
      }   
  
  
      Composite composite = new Composite(tabFolder, SWT.NONE);
              composite.setLayout(new FillLayout());
  
      Group group_1 = new Group(shell, SWT.NONE);
      group_1.setBounds(10, 10, 450, 127);
  
      filename = new Text(group_1, SWT.BORDER);
      filename.setBounds(31, 95, 377, 21);
      filename.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
  
  
      Group group = new Group(group_1, SWT.NONE);
      group.setBounds(81, 46, 245, 43);
  
      Label lblEitherBrowseFor = new Label(group_1, SWT.NONE);
      lblEitherBrowseFor.setBounds(10, 19, 430, 21);
      lblEitherBrowseFor.setText("Either Browse for a file or Try to upload the time table data through Manual entry");
  
      Button btnManual = new Button(group, SWT.NONE);
      btnManual.setBounds(162, 10, 75, 25);
      btnManual.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
  
          }
      });
      btnManual.setText("Manual");
  
      Button btnBrowser = new Button(group, SWT.NONE);
      btnBrowser.setBounds(27, 10, 75, 25);
      btnBrowser.setText("Browse");
      btnBrowser.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
  
              FileDialog dialog = new FileDialog(composite, SWT.NULL);
              String path = dialog.open();
              if (path != null) {
  
                File file = new File(path);
                if (file.isFile())
                {
                    displayFiles(new String[] { file.getAbsolutePath().toString()});
                    DemoShell.parseFile(table, file.toString());
                }
  
                else
                displayFiles(file.list());
  
              }
          }
      });
      ttable_item.setControl(composite);
  
  }
  
  @Override
  protected void checkSubclass() {
      // Disable the check that prevents subclassing of SWT components
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I am getting the following error when trying to add in the above manner.</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
       The constructor FileDialog(Composite, int) is undefined
       Cannot refer to a non-final variable composite inside an inner class defined in a different method</p>
  </blockquote>
  
  <p>I request for suggestions/help to clear the bug or re-do with any other way.</p>