I am relatively new to programming and I am having trouble with my JApplet program. I am looking for a way to get the value for a variable in a different class. I want to use the value of a textField that is created in one class as a cap for a 'for loop' in another class. When the user presses a button, the program should draw a number of pictures equal to the number in the text field.
The program layout is somewhat like this:

public class sampleProgram extends JApplet implements ActionListener{
... JTextField sampleField;
... JButton sampleButton;
... int numPictures;

... public void init{
...... PaintSurface sampleSurface = new PaintSurface();
...... this.add(sampleSurface);
...... JPanel samplePanel = new JPanel();
...... JButton sampleButton = new JButton("Draw");
...... JButton.addActionListener(this)
...... JTextField sampleField = new JTextField(5);
...... samplePanel.add(sampleButton);
...... samplePanel.add(sampleField);
...... this.add(samplePanel);

...... //Scheduled pool thread executor
... }

... public void actionPerformed(actionEvent e){
...... if(e.getSource == sampleButton){
......... numPictures = Integer.parseInt(sampleField.getText());
...... }
... }
}

class AnimationThread(){
... //Animation thread stuff(with repaint())
}

class PaintSurface extends JComponent{
... //import image
... int numberOfPictures = ??????

... public void paint(Graphics g);
...... for(int i = 0; i < numberOfPictures; i++){
......... g.drawImage(image,0,0,this);
...... }
... }
}

So, I need a way for numberOfPictures in the PaintSurface class to access numPictures in the sampleProgram class. I don't know if this is a simple command or if I will need to rewrite everything I have. I have tried using interfaces and objects to get the information but I am not very familiar with either, so I haven't had much luck. Any help would be much appreciated!