 |
 |
java menus disappear
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2002
Status:
Offline
|
|
When a new Java Swing Application project is created in project builder and it is built and run, Hello World is drawn in the window and there are menus such as file and edit in the menubar but when you go to About "app name" the menus disappear. but when you click on the main window or close the aboutbox the menus reappear.
Is there a way to keep the menus always in the menubar i.e not disappearing when other windows than the main window are foremost.
thansk
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Dixon, Ca
Status:
Offline
|
|
Originally posted by road runner:
<STRONG>When a new Java Swing Application project is created in project builder and it is built and run, Hello World is drawn in the window and there are menus such as file and edit in the menubar but when you go to About "app name" the menus disappear. but when you click on the main window or close the aboutbox the menus reappear.
Is there a way to keep the menus always in the menubar i.e not disappearing when other windows than the main window are foremost.
thansk</STRONG>
|
|
So they cloned a sheep - who could tell the difference anyway? - Robin Williams
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Dixon, Ca
Status:
Offline
|
|
Originally posted by road runner:
<STRONG>When a new Java Swing Application project is created in project builder and it is built and run, Hello World is drawn in the window and there are menus such as file and edit in the menubar but when you go to About "app name" the menus disappear. but when you click on the main window or close the aboutbox the menus reappear.
Is there a way to keep the menus always in the menubar i.e not disappearing when other windows than the main window are foremost.
thansk</STRONG>
Oops!
The short answer is that menu bars are added to Frames/JFrames. Since Java has no concept of "global" menu bars, Apple implemented a strategy that permits a windows menu bar to be displayed as the global menu bar when the window is frontmost. In the case of a PB Swing application the About Box window has no menu bar added to it. Compare Welcome.java to AboutBox.java and you will see that a menu bar was added to Welcome.java, but not AboutBox.java. If you want the About Box window to have a menu bar simply cut and paste the code that creates the menu bar in Welcome.java and paste it into AboutBox.java. IMPORTANT! Menu bars can not be shared across multiple windows!
|
|
So they cloned a sheep - who could tell the difference anyway? - Robin Williams
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2002
Status:
Offline
|
|
Originally posted by gandalf:
<STRONG>
If you want the About Box window to have a menu bar simply cut and paste the code that creates the menu bar in Welcome.java and paste it into AboutBox.java. IMPORTANT! Menu bars can not be shared across multiple windows!</STRONG>
thanks for the reply, yeah i tried sharing a menu class with multiple windows with strange results  ... There has to be a better way than to duplicate all the code though.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Dixon, Ca
Status:
Offline
|
|
Originally posted by road runner:
<STRONG>
thanks for the reply, yeah i tried sharing a menu class with multiple windows with strange results  ... There has to be a better way than to duplicate all the code though.</STRONG>
Well, as I said, that was the short answer! The best way I've found to "share" menus is to create Factory classes that create desired menus and menu bars. That way the code is not duplicated, although you do have to call the Factory object to create the menu for each window. The menu content itself is defined in a separate text file which is parsed and used to construct the menus. I can email you some sample code if you'd like.
|
|
So they cloned a sheep - who could tell the difference anyway? - Robin Williams
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |