Results 1 to 4 of 4
- 05-05-2011, 06:05 PM #1
Member
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
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
- 05-05-2011, 06:21 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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{
- 05-05-2011, 10:10 PM #3
Member
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
Thank you so much!!!
- 05-05-2011, 10:12 PM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You are welcome. Please mark your thread solved with the thread tools at the top of the page.
Similar Threads
-
JavaBean - invalid method declaration and return type required
By jprog in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 05-07-2011, 06:13 PM -
Err: invalid method declaration; return type required
By Die The Villain in forum New To JavaReplies: 12Last Post: 04-15-2011, 12:44 AM -
invalid method declaration; return type required
By XaviannNJ in forum JCreatorReplies: 7Last Post: 11-25-2010, 01:59 PM -
Error: invalid method declaration; return type required
By silvia in forum AWT / SwingReplies: 3Last Post: 06-05-2010, 08:05 PM -
invalid method declaration error
By bsarules in forum Java AppletsReplies: 7Last Post: 05-25-2010, 06:06 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks