File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error when calling a constructor

 
Jesse Walker
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an error when calling a constructor that makes a JMenu, just one menu with menu items, but it gives me an incompatible error when I call it
Here is the code

JMenu file = new StandardMenu();

what is wrong with it, the constructor is a public void, so it doesnt return anything. Im pulling my hair out at this one, so any help can be appreciated
Thanks
Jess
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructors don't have a return type - it should look like

public StandardMenu() {
...
}
 
Joyce Lee
Ranch Hand
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your StandardMenu a subclass (directly or indirectlly) of JMenu?

For example:


Joyce
 
Tim Leung
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JMenu objJMenu=new StandardMenu()

This declaration is only vaild
StandardMenu is a sub-class of JMenu
 
Jesse Walker
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my constructor doesnt have a return type. And if I change the StandardMenu to be a subclass of JMenu then the call should work, that makes sense I did the same thing with a frame but I subclass the class I made from JFrame, I feel stupid now but thanks for your help.
Jess
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic