View Full Version : Illegal Forward Reference
The Soul
08-27-2009, 07:26 AM
Well I'm creating a simple UI for learning purposes and it's not working out too well. It's a program that has the user input a specific file/directory, click the button and it's deleted. The problem is, I'm getting an error when using the jTextField.
An example:
String filename = "";
filename = TextField1.getText();
File delfile = new File(filename);
The error is on the second line of that code block. I'm all out of ideas...
Note that there isn't a help section here, so I thought this was the most logical section to put this in.
hypeness
08-27-2009, 04:24 PM
Well I'm creating a simple UI for learning purposes and it's not working out too well. It's a program that has the user input a specific file/directory, click the button and it's deleted. The problem is, I'm getting an error when using the jTextField.
An example:
String filename = "";
filename = TextField1.getText();
File delfile = new File(filename);
The error is on the second line of that code block. I'm all out of ideas...
Note that there isn't a help section here, so I thought this was the most logical section to put this in.
in java of course i would say put a "catch exeption (e);"? cuz when i got an error i just put that at the bottom of your class... dunno maybe make a crash handler something i dont see any errors.
or make a public void TextField1 {. as i sed i see no errors :rolleyes:
The Soul
08-27-2009, 11:54 PM
in java of course i would say put a "catch exeption (e);"? cuz when i got an error i just put that at the bottom of your class... dunno maybe make a crash handler something i dont see any errors.
or make a public void TextField1 {. as i sed i see no errors :rolleyes:
That wouldn't work but thanks for your concern.
Jesse
08-28-2009, 01:54 AM
The default name for a text field is jTextField1.
The Soul
08-28-2009, 02:24 AM
The default name for a text field is jTextField1.
I changed the variable name.
Anyways, I fixed it.
I just created a seperate method to hold the data being collected:
public String getFileName() {
filename = TextField1.getText();
return filename;
}
File delfile = new File(getFileName());
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.