Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2004

Tip: Looking for answers? Try searching our database.

Syntax error in Eclipse on super()

Thread view: 
Girish Chavan - 23 Aug 2004 14:48 GMT
This has me stumped!!
I receive an error in Eclipse on the line 'super("Unlock");'
saying :  ' Syntax error on token "(" , "." expected  '

Now when I comment that line out, the next super gives the same error.

What is puzzling is that the ConstrainAction class, which calls super
similarly doesn't create any problems for Eclipse at all.
------------------------------------------------

class lockAction extends AbstractAction{

    lockAction()
    {
        if(isLocked())
            super("Unlock");
        else
            super("Lock");
           
    }
   
    public void actionPerformed(ActionEvent e)
    {
        lockButton.setSelected(!isLocked()); //TOGGLE
    }
}

class constrainAction extends AbstractAction{

    constrainAction()
    {
        super("Set Constraints");
    }
    public void actionPerformed(ActionEvent e)
    {
        ;
   
    }
}
Andrew Thompson - 23 Aug 2004 15:03 GMT
> This has me stumped!!

Do you have ..any idea what you are doing?

I removed the crap, and all the stuff you
apparently made up, fixed the nomenclature
and came up with this..

<sscce>
import java.awt.event.*;
import javax.swing.*;

class LockAction extends AbstractAction{

 LockAction() {
   super("Unlock");
 }

 public void actionPerformed(ActionEvent e) { ; }
}

class ConstrainAction extends AbstractAction{

 ConstrainAction() {
   super("Set Constraints");
 }

 public void actionPerformed(ActionEvent e) { ; }
}
</sscce>

It compiles, but does nothing, at least nothing
useful.  However to get more intelligent answers
you need to ask more completely described questions.

Back to you.

[ By the way, this has nothing to do with Eclipse. ]

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Girish Chavan - 23 Aug 2004 20:16 GMT
Thanks for the reply. My post was obviously part of my code, not the
whole lot, hence it probably didnt make sense. What I was trying to do
is set the Action Name based on the result of some other method.
Didnt realize that the call to super() has to be the first thing in
the constructor, and Eclipse gave a very weird message, which kinda
put me off on the wrong track.
Morten Alver - 23 Aug 2004 15:17 GMT
This is the error message I get when trying to compile (an edited
version of) your example:

lockAction.java:6: call to super must be first statement in constructor
                        super("Unlock");

It is probably more helpful than the message you got. To solve your
problem, just use the default constructor and set the action name
afterwards with putValue(NAME, "Unlock") or putValue(NAME, "Lock").

--
Morten
Girish Chavan - 23 Aug 2004 20:11 GMT
> This is the error message I get when trying to compile (an edited
> version of) your example:
[quoted text clipped - 5 lines]
> problem, just use the default constructor and set the action name
> afterwards with putValue(NAME, "Unlock") or putValue(NAME, "Lock").

----------
Thanks a lot. It WAS way more helpful than the previous reply.
Eclipse didnt give a very descriptive error message, hence the confusion.
Andrew Thompson - 23 Aug 2004 20:39 GMT
> Eclipse didnt give a very descriptive error message,

Eclipse gives the same error message as the
java compiler.  Again, so this time it might
sink in, Eclipse is *not* the problem.
<http://www.xdweb.net/~dibblego/java/faq/answers.html#q34>

For future reference on those confusing
error messages, see
<http://www.physci.org/codes/javafaq.jsp#exact>
it links to the error messages explanations
at mindprod.com.  [ You may notice that your
'Eclipse' error is listed. ]

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.