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.
Java class:
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;
}
(...)
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);
(...)
}
}
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.
Here's the JFrame 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:
}
(...)
}
How can I do this?