• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMenu trouble

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recommended reading
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html
 
Jeff Yan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic