title: Passing values from jframe to java class in netbeans
body: <p>in netbeans I've got a JFrame and a JavaClass. In my JFrame I have a combobox to select a file that will be used in the operations within the Java class.</p>
  
  <p>Java class:</p>
  
  <pre><code>public class WekaTest {
      public static BufferedReader readDataFile(String filename) {
          BufferedReader inputReader = null;
  
          try {
              inputReader = new BufferedReader(new FileReader(filename));
          } catch (FileNotFoundException ex) {
              System.err.println("Ficheiro " + filename + " não encontrado");
          }
  
          return inputReader;
      }
  </code></pre>
  
  <p>(...)</p>
  
  <pre><code>    public static void main(String[] args) throws Exception {
  
          JFrame1 form = new JFrame1();
          form.setVisible(true);
  
          BufferedReader datafile = readDataFile("weather.nominal.arff");
  
          Instances data = new Instances(datafile);
          data.setClassIndex(data.numAttributes() - 1);
  
          (...)
  
      }
  
  }
  </code></pre>
  
  <p>What I need is, from the JFrame's combobox, to select a different datafile to read from. So, as I change the selected item in my combobox, I want to set my datafile as that value.</p>
  
  <p>Here's the JFrame code:</p>
  
  <pre><code>public class JFrame1 extends javax.swing.JFrame {
  
      public JFrame1() {
          initComponents();
      }
  
     (...)                       
  
      private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
          // TODO add your handling code here:
          jTextField1.setText(arffComboBox.getSelectedItem().toString());;
  
      }                                        
  
      private void arffComboBoxActionPerformed(java.awt.event.ActionEvent evt) {                                             
          // TODO add your handling code here:
      }                                            
  
  (...)               
  }
  </code></pre>
  
  <p>How can I do this?</p>