Results 1 to 4 of 4
  1. #1
    bremzb is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default Invalid Method Declaration; Return Type Required

    import java.awt.*;
    import java.awt.event.*;

    public class MouseClickAss{
    TextField objTextField1;
    TextField objTextField2;
    public static void main(String[] args){
    MouseClick MC = new MouseClick();
    }

    public MouseClick(){


    Frame f=new Frame("Checking the mouse click");
    Button button=new Button("Click Me");
    button.setBounds(100,150,70,70);
    button.addMouseListener(new MyMouseListener());

    Here is the beginning of my code. The error is pointing at public MouseClick(){. It says Invalid Method Declaration; Return Type Required. Please Help. Thanks

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    There is quite a bit wrong with that. Is MouseCLick() a method? If so, it should be mouseClick. If it is a method, it needs a return type as the error says. Public is not one, a return type is void, or any class or primitive. I am assuming it is a class. To create a class you need to say it's a class.
    Java Code:
    public class MouseClick{

  3. #3
    bremzb is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    Thank you so much!!!

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You are welcome. Please mark your thread solved with the thread tools at the top of the page.

Similar Threads

  1. JavaBean - invalid method declaration and return type required
    By jprog in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 05-07-2011, 07:13 PM
  2. Err: invalid method declaration; return type required
    By Die The Villain in forum New To Java
    Replies: 12
    Last Post: 04-15-2011, 01:44 AM
  3. invalid method declaration; return type required
    By XaviannNJ in forum JCreator
    Replies: 7
    Last Post: 11-25-2010, 02:59 PM
  4. Replies: 3
    Last Post: 06-05-2010, 09:05 PM
  5. invalid method declaration error
    By bsarules in forum Java Applets
    Replies: 7
    Last Post: 05-25-2010, 07:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •