• 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

a question about JApplet and JMenuBar

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have put the JMenuBar and JMenuItems into a JApplet, but the JMenuItems can not work. I can only see the main menu. Can anyone tell me, what's the problem?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

JMenuItems go into JMenus, and the JMenus go into the JMenuBar. If you put JMenuItems directly into a JMenuBar, it won't work.
 
Baosheng Ma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Absolutely right, and I have done it just like what you have said. Taht is, I have made a JMenuBar, put 3 JMenu into the JMenuBar, and put several JMenuIdems into the JMenu. But it doesn't work. when I click the mainmenu, the menuitem can not be displayed. I just can not understand.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, let's see. One thing that might be wrong is if you've put a heavyweight component like Canvas into your JApplet's content area; that would stop the menus from appearing. Otherwise, let's see the menu-related code -- as little code as you can post and still show what you've done, please.
 
Baosheng Ma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, yesterday I have tested the code and I have found where the problem is, but I don't know yet, how can I solve the problem. I post the source code up. The code is really a little bit complex. I try to explain it clearly. There are 2 classes. One is a abstract basic class, named GraphGame. The other is subclass, named TSPGame. The problem is in the first basic class, GraphGame. Its main function is to make the User Graphic Interface. What I have found is all because this code: 'contentPane.add(_p, BorderLayout.CENTER);', the line 157. _p is a panel, this panel ist the container of other elements. I put the other elements onto this panel, and then put this panel into JApplet. But whenever I add the panel _p on the JApplet, this panel will cover the submenus up. Whenever I delete this line, the submenus will be appeared, (the mainmenu can always be seen). That is, when I add the panel onto JApplet and then click the mainmenu, the submenu works, but we can not see them, because they are covered by the panel _p. when I change the code like this: 'contentPane.add(_p, BorderLayout.EAST);', then we can see all the submenus, and the panel is on the right side of the JApplet. Of cause, this is not the way to solve the problem and there must be anything wrong with these elements.

Weil die Code nicht von mir gemacht wird, habe ich sie gel�scht.
[ May 21, 2006: Message edited by: Baosheng Ma ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Baosheng-

I added CODE tags to your code, so that it stays formatted and is more easily readable. You should use those when posting ocde of any length. Look for the "CODE" button underneath the text editing box when posting.
 
Baosheng Ma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
das Problem habe ich gel�st. Und alles wegen des Zusammenhang zwischen der leichten Component und schweren Component. Ich habe das Panel auch zu JPanel umgesetzt, und es funktioniert wunderbar!

[EJFH: Babelfish says: ]


I solved the problem. And everything because of connection between the easy Component and heavy Component. I converted the panel also to JPanel, and it functions marvelously!


[ May 21, 2006: Message edited by: Ernest Friedman-Hill ]
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ummm... yeah. That's what I said, wasn't it?
 
Baosheng Ma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Ernest, verstehst du auch Deutsch? Bist du Deutscher? Ich bin nur ein bi�chen neugieri! Und danke f�r deinen Hinweis!
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


do you understand also German? Are you German? I am only a little neugieri! And thanks for your reference!



No, I'm using http://babelfish.altavista.com . I get questions by email all the time that aren't in English; apparently there are people who are convinced I can speak Portuguese, especially. But no, I'm terrible with languages -- despite studying Spanish for four years, I can't even do a passable job with that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic