wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Can't resolve compiler error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic
Author

Can't resolve compiler error message

Ryan Perlman
Greenhorn

Joined: Oct 31, 2001
Posts: 23
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

Joined: Jul 13, 2001
Posts: 269
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't resolve compiler error message
 
Similar Threads
printing an 2d array by row
Confused...
Using .getText() and .append()
Changing an arrays size
Concordancer