codice:
public class ApriARFF extends JPanel {// implements ActionListener {
private JTextField relazioneT;
private JTextField istanzeT;
private JTextField attributiT;
/**
* Create the panel.
*/
public ApriARFF(String relation, Enumeration attributi, Enumeration istanze,String file) {
setLayout(null);
this.relation=relation;
this.attributi=attributi;
this.istanze=istanze;
this.fileName=file;
JPanel caratteristicheArff = new JPanel();
caratteristicheArff.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "caratteristiche arff", TitledBorder.LEADING, TitledBorder.TOP, null, null));
caratteristicheArff.setBounds(10, 26, 436, 107);
add(caratteristicheArff);
caratteristicheArff.setLayout(null);
JLabel relationL = new JLabel("Relazione");
relationL.setBounds(24, 25, 60, 14);
caratteristicheArff.add(relationL);
JLabel istanceL = new JLabel("Istanze");
istanceL.setBounds(24, 68, 60, 14);
caratteristicheArff.add(istanceL);
JLabel attributiL = new JLabel("Attributi");
attributiL.setBounds(229, 25, 60, 14);
caratteristicheArff.add(attributiL);
relazioneT = new JTextField();
relazioneT.setBounds(94, 22, 86, 20);
caratteristicheArff.add(relazioneT);
relazioneT.setColumns(10);
relazioneT.setText(relation);
istanzeT = new JTextField();
istanzeT.setBounds(94, 62, 86, 20);
caratteristicheArff.add(istanzeT);
istanzeT.setColumns(10);
attributiT = new JTextField();
attributiT.setBounds(288, 22, 86, 20);
caratteristicheArff.add(attributiT);
attributiT.setColumns(10);
JPanel contenutoArff = new JPanel();
contenutoArff.setBorder(new TitledBorder(null, "contenuto arff", TitledBorder.LEADING, TitledBorder.TOP, null, null));
contenutoArff.setBounds(10, 156, 436, 257);
add(contenutoArff);
JTextArea areaTesto = new JTextArea();
JScrollPane scroll1;
contenutoArff.setLayout(new BorderLayout(0, 0));
scroll1 = new JScrollPane(areaTesto,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll1.setLayout(new ScrollPaneLayout());
contenutoArff.add(scroll1);
areaTesto.setBounds(10, 23, 388, 223);
areaTesto.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
//contenutoArff.add(areaTesto);
int count=0;
while(this.attributi.hasMoreElements())
{
areaTesto.append(attributi.nextElement().toString()+"\n");
count++;
}
attributiT.setText(String.valueOf(count));
count=0;
areaTesto.append("@data \n");
while(this.istanze.hasMoreElements())
{
areaTesto.append(istanze.nextElement().toString()+"\n");
count++;
}
istanzeT.setText(String.valueOf(count));
JPanel regoleAssociative = new JPanel();
regoleAssociative.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "regole associative", TitledBorder.LEADING, TitledBorder.TOP, null, null));
regoleAssociative.setBounds(473, 26, 167, 386);
add(regoleAssociative);
regoleAssociative.setLayout(null);
JLabel tipoDiAlgoritmo = new JLabel("Tipo di algoritmo:");
tipoDiAlgoritmo.setBounds(10, 39, 130, 23);
regoleAssociative.add(tipoDiAlgoritmo);
JComboBox scegliAlgoritmoC = new JComboBox();
scegliAlgoritmoC.setModel(new DefaultComboBoxModel(new String[] {"", "Apriori"}));
scegliAlgoritmoC.setBounds(10, 73, 147, 23);
regoleAssociative.add(scegliAlgoritmoC);
JButton analizzaB = new JButton("analizza");
analizzaB.setBounds(36, 352, 89, 23);
regoleAssociative.add(analizzaB);
System.out.println(this.fileName);// qui ho il valore corretto di fileName
AprioriControllore g=new AprioriControllore(this.fileName);
analizzaB.addActionListener(g);
}
class AprioriControllore implements ActionListener
{
public AprioriControllore(String f)
{
a=f;
System.out.println("interno "+a);// qui ho il valore corretto di fileName
}
public void actionPerformed(ActionEvent e)
{
AprioriVista a=new AprioriVista(this.a);
System.out.println("actionPerformed: "+this.a);//valore scorretto, riferito all'oggetto string precedente
}
private String a;
}
private String relation;
private Enumeration attributi;
private Enumeration istanze;
private String fileName;
}