Please Disregard I figured out the errors of my way.. Thanks Ryan
I have a button that says print: when pushed i want to print my array: heres is the error message that I get: Cannot Resolve Symbol: Symbol: Variable input Location: class FirstArray Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FirstArray extends JApplet implements ActionListener { JLabel label = new JLabel("enter Integers's"); JTextField inputText = new JTextField(10); JTextArea output = new JTextArea(10,15); JScrollPane sp = new JScrollPane( output ); JButton print = new JButton("Print Array"); int count = 0;
public void init() { Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(label); c.add(inputText); inputText.addActionListener(this); c.add(sp); c.add(print); print.addActionListener(new display());
}
public void actionPerformed(ActionEvent e) { int[] input = new int[20];
if ( count < input.length ){ input[count] = Integer.parseInt(inputText.getText()); output.append(Integer.toString(input[count]) + "\n"); inputText.setText(""); showStatus("Please Enter Another Integer"); count++; } if( count == input.length){ output.append("Thank You\n" + "Your Done\n\n"); showStatus("Your Done"); inputText.setEditable(false); } } private class display implements ActionListener { public void actionPerformed(ActionEvent e) { for(int i = 0; i < input.length; i++){ output = output.append(Integer.toString(input[i])); } } } }
[This message has been edited by Ryan Perlman (edited November 15, 2001).]
The variable input is local to the method actionPerformed in the class FirstArray. So you can not access it from your local inner class Display. You should make input an instance variable for example. W.
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
a bit of art, as a gift, the permaculture playing cards