title: SWT Method - Getting a value from the table viewer / Swing Method - Using the value
body: <p>I have a method in my SWT class that gets the selected value from my table.  The value is actually the file name of the object.</p>
  
  <pre><code> public String getPDFFileName() { 
      int row = viewer.getTable().getSelectionIndex();
      if (row != -1) {
         return pdfFileName = AplotSaveDataModel.getInstance().getSelectedPDFFileName(row);
      }
      else {
         MessageDialog.openError(null, "PDF Selection Error Message", "You need to select a PDF to view.");
      }
      return null;
    }
  </code></pre>
  
  <p>I have a composite in the same class that is bridging SWT and Swing.  This method takes the String Filename and creates a Swing Viewer displaying the file.</p>
  
  <pre><code> protected Control createPDFButtons(Composite parent) {
    final Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
    GridData mainLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false); 
    mainLayoutData.horizontalSpan = 1; 
    swtAwtComponent.setLayoutData(mainLayoutData); 
    GridLayout mainLayout = new GridLayout(1, false); 
    mainLayout.marginWidth = 0; 
    mainLayout.marginHeight = 0; 
    swtAwtComponent.setLayout(mainLayout); 
    final Frame frame = SWT_AWT.new_Frame(swtAwtComponent);
    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); 
  
    JButton viewerButton = new JButton("View Selected PDF");
    viewerButton.addActionListener(new ActionListener(){
       public void actionPerformed(ActionEvent actionevent) {
  
          final File viewerFile = new File(getPDFFileName());
          final AplotPdfViewer pdfv = new AplotPdfViewer(true);
          try {
             pdfv.openFile(viewerFile);
          }
          catch (IOException e) {
             e.printStackTrace();
          }
  
       }
    });
  
    panel.add(viewerButton);
    frame.add(panel);
    return swtAwtComponent;
  }      
  </code></pre>
  
  <p>If I try and run the getPDFFileName() in the composite, I get a SWT thread error.  I understand where that comes from.</p>
  
  <p>I am not sure how to get the value from getPDFFileName() and use it in final File viewerFile = new File("NEED FILENAME OF SELECTION");</p>