Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenu trouble  RSS feed

 
Jeff Yan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey all, i have a main class and a menu class, in the main class i have a JFrame, and in the menu class it just creates the menu (file, edit etc) without putting it in a frame! is there any way to put that menu in the JFrame of the main class? if so . . . how? ive been trying to figure it out for ages.

ive tried creating a new object of the menu class and adding that into the JFrame like this:
but it doesnt work!

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Jeff Yan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i have created the menu correctly and done all that, but IN A DIFFERENT CLASS. how do i use that menu in the other class? i have tried to do but it comes up with non static method create() cannot be referenced from a static context.
when i try and set the method create() to static it comes up with all these errors saying cannot use * variable from a static context! its really annoying! HELP :s
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should NOT be using any static methods in your classes. If you are it is poor design.

Again, read the Swing tutorial for working examles.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!