I have 2 classes, one of which also has a nested class:
1. Home.java (extends JApplet)
2. Away.java (extends JPanel) has nested class, private class ButtonListener implements ActionListener
Now in Home.java I have a Vector ( called bankaccount) which i pass to the Constructor of Away.java ( I declared the vector again there as an instance by Private Vector bankaccount;
My problem is that in ButtonListener I am trying to access the Vector so that i can modify it when a button has been clicked, and i thought i could just use the commands of bankaccount.add() and bankaccount.get() directly, however it seems like ButtonListener cannot access the Vector, even though i passed it along to the Constructor of the Away class.
Any suggestions on how i get access the Vector from the ButtonListenere class?
Here is a simplified version of what i am trying to do:
public class Home extends JApplet
{
private Away away;
private Vector bankaccount;
public void init()
{
bankaccount = new Vector();
away = new Away(bankaccount);
}
}
public class Away extends JPanel
{
private Vector bankaccount;
JTextArea text1= new JTextArea(50,50);
public Away(Vector bankaccount)
{
//declare buttons,textarea,setLayout,etc
button1.addActionListener (new ButtonListener());
//i can set text1.setText(( String)bankaccount.get(0));
// here to access bankaccount, and it shows up fine, but i want
// do it in from the class below
}
private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//trying to access bankaccount here by doing:
// but it is not doing anything
text1.setText(( String)bankaccount.get(0));
}
}