Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: WHY this code dont work?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default WHY this code dont work?

     alcher.addActionListener(new ActionListener(scriptMenu)
          {
            public void actionPerformed(ActionEvent arg0) {
              while (true) {
                if (BSBotClient.username == null ? "" != null : !BSBotClient.username.equals("")) if (BSBotClient.password == null ? "" != null : !BSBotClient.password.equals(""))
                    break; BSBotClient.username = JOptionPane.showInputDialog("Enter username:");
                BSBotClient.password = JOptionPane.showInputDialog("Enter password:");
                if (BSBotClient.username == null ? "" != null : !BSBotClient.username.equals("")) if (BSBotClient.password == null ? "" != null : !BSBotClient.password.equals(""))
                    continue;
                JOptionPane.showMessageDialog(null, "Please enter something atleast");
              }
     
              BSBot.bsBot.scriptHandler.playScript(new BSScriptPaladinThiever(BSBot.bsBot));
              this.val$scriptMenu.setEnabled(false);
            }
          });

    eclipse gives this error:
    The constructor Object(Menu) is undefined

    is there way to fix this?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: WHY this code dont work?

    Why are you giving your ActionListener's constructor an argument? It doesn't take any parameters.

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: WHY this code dont work?

    Quote Originally Posted by KevinWorkman View Post
    Why are you giving your ActionListener's constructor an argument? It doesn't take any parameters.
    what u mean with that? can you explain

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: WHY this code dont work?

    You have: new ActionListener(scriptMenu)

    Where do you see a constructor for ActionListener that takes an argument?

    More accurately, you're using an anonymous inner class to indirectly instantiate an interface, which has no constructor. So that goes to Object's constructor, and where do you see a constructor for Object that takes an argument?

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: WHY this code dont work?

    Quote Originally Posted by KevinWorkman View Post
    You have: new ActionListener(scriptMenu)

    Where do you see a constructor for ActionListener that takes an argument?

    More accurately, you're using an anonymous inner class to indirectly instantiate an interface, which has no constructor. So that goes to Object's constructor, and where do you see a constructor for Object that takes an argument?
    well can you tellme how to fix this?

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: WHY this code dont work?

    Quote Originally Posted by sibbe View Post
    well can you tellme how to fix this?
    I told you what the problem is. What don't you understand?

  7. #7
    Junior Member
    Join Date
    Oct 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: WHY this code dont work?

    Quote Originally Posted by KevinWorkman View Post
    I told you what the problem is. What don't you understand?
    well im not good at java <.< so maybe thats why

  8. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: WHY this code dont work?

    Quote Originally Posted by sibbe View Post
    well im not good at java <.< so maybe thats why
    Then perhaps it's time to go back over the basic tutorials: The Java™ Tutorials

Similar Threads

  1. [SOLVED] I dont know how to complete this code?
    By jwb4291 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 8th, 2017, 11:11 PM
  2. please tell me why this code does not work
    By amr in forum Java Theory & Questions
    Replies: 9
    Last Post: December 6th, 2010, 06:46 PM
  3. [SOLVED] "possible loss of precision", except not, code doesn't work, simple question
    By Perd1t1on in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 24th, 2010, 07:11 PM
  4. I dont get it....please help
    By DestinyChick1225 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: June 30th, 2010, 03:16 AM
  5. Dont laugh at me
    By Neblin in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 3rd, 2009, 08:18 AM