JavaFX Symbol not found, referring from class
this might be a stupid question but I'm trying to access a text area from
my new Gui through the controller which uses its own class (as simple as
they are) when i run the program it comes up with the symbol not defined.
I'm not sure where im going wrong.
Here is the Code:
External Class
package dataget;
import java.io.*;
public class ReadWrite {
public void ReadFileContents(String fileName) {
try {
BufferedReader in = new BufferedReader(new FileReader(fileName));
int lineNumber = 0;
int currentLine;
String lines[];
while (in.readLine() != null) {
lineNumber++;
}
in.close();
lines = new String[lineNumber];
BufferedReader inLines = new BufferedReader(new
FileReader(fileName));
for (currentLine = 0; currentLine < lineNumber;) {
lines[currentLine] = inLines.readLine();
txtareaOutput.appendText(lines[currentLine]);
currentLine++;
}
inLines.close();
txtareaStatus.appendText("Lines in File: " + lineNumber);
} catch (IOException ioe) {
System.out.println("File not found!");
}
}
And now the Controller Class:
public class MainController implements Initializable {
@FXML
private TextField txtName;
@FXML
private TextField txtAge;
@FXML
private ComboBox comboGender;
@FXML
private Button btnRead;
@FXML
private Button btnWrite;
@FXML
private TextArea txtareaStatus;
@FXML
private TextArea txtareaOutput;
@FXML
public void clickRead(){
ReadWrite read = new ReadWrite();
read.ReadFileContents("data/dylans/data.txt");
}
}
I omitted a few lines since they are irrelevant (they are all in the same
DataGet Package)
And i keep getting "error: cannot find symbol":
Compiling 2 source files to C:\Apps\NetBeans 7.3.1\Dylans
Projects\DataGet\build\classes
C:\Apps\NetBeans 7.3.1\Dylans Projects\DataGet\src\dataget\ReadWrite.java:28:
error: cannot find symbol txtareaOutput.appendText(lines[currentLine]);
symbol: variable txtareaOutput
location: class ReadWrite
C:\Apps\NetBeans 7.3.1\Dylans Projects\DataGet\src\dataget\ReadWrite.java:34:
error: cannot find symbol txtareaStatus.appendText("Lines in File: " +
lineNumber);
symbol: variable txtareaStatus
location: class ReadWrite 2 errors
Do i have to declare the textarea within the original class file where the
object is created from?
thanks.
No comments:
Post a Comment