Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't resolve compiler error message

 
Ryan Perlman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ryan Perlman:
[B]

[/B]

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic