Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

MenuBar help

  • 14-03-2010 9:31pm
    #1
    Registered Users, Registered Users 2 Posts: 3,627 ✭✭✭


    I copied this guys code word for word,and i keep getting an error..can someone please help.Im using jgrasp.

    http://www.youtube.com/user/MrJavaHelp#p/c/DD1BAED03F791E1B/3/dwLkDGm5EBc
    import javax.swing.*;
       
       import java.awt.Event.*;
    
        public class menu {
       
           public static void main(String[] args){
             JFrame frame = new JFrame("Menu");
             frame.setVisible(true);
             frame.setSize(400,200);
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          	
             JMenuBar menubar = new JMenuBar();
             frame.setJMenuBar(menubar);
          	
             JMenu file = new JMenu("File");
             menubar.add(file);
             JMenuItem exit = new JMenuItem("Exit");
             file.add(exit);
          	
          	
             JMenu help = new JMenu("Help");
             menubar.add(help);
             JMenuItem about = new JMenuItem("About");
             help.add(about);
          	
             class exitaction implements ActionListener{
                 public void actionPerformed (ActionEvent e){
                   System.exit(0);
                }
             }
             exit.addActionListener(new exitaction());
          }
       }
    

    the error i get is as follows
    menu.java:27: cannot find symbol
    symbol  : class ActionListener
    location: class menu
             class exitaction implements ActionListener{
                                         ^
    menu.java:28: cannot find symbol
    symbol  : class ActionEvent
    location: class exitaction
                 public void actionPerformed (ActionEvent e){
                                              ^
    menu.java:32: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (exitaction)
             exit.addActionListener(new exitaction());
                 ^
    3 errors
    
     ----jGRASP wedge2: exit code for process is 1.
     ----jGRASP: operation complete.
    

    Does anyone also have any links to any good guides on how to do random access files in java..All i want is basic and to the point.


Comments

  • Registered Users, Registered Users 2 Posts: 2,082 ✭✭✭Tobias Greeshman


    I think you have a typo in your second import it should be a lowercase 'e' in event.
    // ...
    import java.awt.event.*;
    


  • Registered Users, Registered Users 2 Posts: 1,916 ✭✭✭ronivek


    I'd be tempted to say your import statement is incorrect.

    It should be:
    [PHP]
    import java.awt.event.*;
    [/PHP]

    And NOT:
    [PHP]
    import java.awt.Event.*;
    [/PHP]

    You should also really follow the standard Java convention for naming classes; i.e. CamelCase names beginning with an uppercase letter.

    EDIT: I didn't see the other reply :(


  • Registered Users, Registered Users 2 Posts: 3,627 ✭✭✭Fol20


    thanks ,thats the problem.its sorted now


  • Registered Users, Registered Users 2 Posts: 3,627 ✭✭✭Fol20


    using netbeans..what does this error mean
    java.lang.VerifyError: (class: logon/LogonApp, method: <init> signature: ()V) Constructor must call super() or this()
    Exception in thread "main" Java Result: 1


Advertisement