Here is some code that is not working, at the moment i am just trying
to use a button on a gui screen to display some text on the command
line...this is in a OpenFiles.class, simply prints out "text".
submenu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
OpenFiles fo = new OpenFiles();
fo.process();
}
});
But it will not allow me to compile this class and error is:
OpenFiles cannot be applied to ()
I have tried putting argStrings in but it will say local variable
argStrings is accessed from within inner class and needs to be declared
final.
Any help would be appreciated
Arophous
Andrew Thompson - 21 Nov 2005 11:26 GMT
> Here is some code that is not working,
Sleepy is it[1]? ;-)
> ...I have tried putting argStrings
?? What is 'argStrings', and for that matter, what is
OpenFiles? If you are having problems with code, it
is best to post exact error messages[1], and an SSCCE[2].
[1] <http://www.physci.org/codes/javafaq.jsp#exact>
[2] <http://www.physci.org/codes/sscce.jsp>
>...in but it will say local variable
> argStrings is accessed from within inner class and needs to be declared
> final.
final String argStrings;
> Any help would be appreciated
A better group for Java beginners is..
<http://www.physci.org/codes/javafaq.jsp#cljh>
And since you may also be a usenoob, a few notes on your
web interface to usenet.
<http://www.physci.org/codes/javafaq.jsp#usenet>
HTH

Signature
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.
Roedy Green - 21 Nov 2005 11:32 GMT
>But it will not allow me to compile this class and error is:
>OpenFiles cannot be applied to ()
it is telling you there is no such thing as the OpenFiles()
constructor?
Is there a public OpenFiles class? Is it imported? does it have such
a contructor?
did you spell it Openfiles somewhere else?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
John C. Bollinger - 22 Nov 2005 02:41 GMT
> submenu.addActionListener(new ActionListener()
> {
[quoted text clipped - 7 lines]
> But it will not allow me to compile this class and error is:
> OpenFiles cannot be applied to ()
That means that the OpenFiles class' constructor requires at least one
argument. You will need to supply the appropriate argument(s).
> I have tried putting argStrings in but it will say local variable
> argStrings is accessed from within inner class and needs to be declared
> final.
That means precisely what it says. If the argument you pass to the
constructor is a local variable in the method containing that statement
then the variable must be declared final. Method parameters count as
local variables in this regard (and can very well be declared final if
so desired).

Signature
John Bollinger
jobollin@indiana.edu