what happend to my code?how to transfer variable between components?
the code is to get some letter from upper textarea, then click 'filter' button this string will pass to the class variable. and then when i click the 'next' button to display this class varible, nothing in there. what happened?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
public class GUI
{
public static void main(String arg[])
{
String testS=new String();
JLabel jl=new JLabel("WebSite Address: ");
JTextField jtf=new JTextField(35); // user input text field
JTextArea displayArea=new JTextArea(60,30); // display text area
displayArea.setLineWrap(true);
JScrollPane jsp=new JScrollPane(displayArea);
JLabel filterLabel=new JLabel("Input filter symbols: ");
JTextArea filterArea=new JTextArea(4,30);
JPanel jp1= new JPanel(); // upper panel of application
jp1.add(jl);
jp1.add(jtf);
jp1.add(new NEXTButton(jtf,displayArea,testS)); // next button
JPanel jp2=new JPanel(); //bottom panel of app
jp2.add(filterLabel);
jp2.add(filterArea);
jp2.add(new FilterButton(filterArea,testS));
JFrame jf=new JFrame("Spider");
jf.setDefaultLookAndFeelDecorated(true);
jf.setSize(600,400);
jf.setLayout(new BorderLayout());
jf.getContentPane().add(jp2,BorderLayout.NORTH);
jf.getContentPane().add(jsp,BorderLayout.CENTER);
jf.getContentPane().add(jp1,BorderLayout.SOUTH);
jf.setVisible(true);
}
private static class NEXTButton extends JButton implements ActionListener{
JTextField jtf;
JTextArea jta;
ArrayList filterAL;
String testS;
public NEXTButton(JTextField jtf,JTextArea jta,String s){
super("Next");
this.jtf=jtf;
this.jta=jta;
this.testS=s;
addActionListener(this);
}
public void actionPerformed(ActionEvent e){
System.out.println(this.testS);
}
}
private static class FilterButton extends JButton implements ActionListener{
JTextArea filterArea;
String testS;
public FilterButton(JTextArea filterArea,String s){
super("Filter");
this.filterArea=filterArea;
this.testS=s;
addActionListener(this);
}
public void actionPerformed(ActionEvent e){
try{
this.testS=this.filterArea.getText();
System.out.println(this.testS);
}catch(Exception ex){}
}
}
}

