Board index » jbuilder » Jmenubar on multiple frames

Jmenubar on multiple frames


2005-03-10 10:47:29 PM
jbuilder21
HI
I am facing problem to set jmenubar on more than one frame.
Is i have to replicate all code (and events) on other frame files (or there is other technique).
Other problem is When any menuitem is clicked and other frame is opened the time between previous frame and new frame is longer (as i construct new frame,calling its setvisible(true) and old frame false)
I am developing standalone desktop application.
Did u people know any solution
Hussaan
 
 

Re:Jmenubar on multiple frames

"hussan" < XXXX@XXXXX.COM >wrote in message
Quote

HI

I am facing problem to set jmenubar on more than one frame.
Is i have to replicate all code (and events) on other frame files (or
there is other technique).

Most people would use an MDI application in this scenario, so that the Top
level or MainFrame is the one to which the JMenuBar would be owned.
Of course, even then, you would want to provide (in the ideal world), some
level of abstraction. For instance, some JInternalFrames you display, might
need menu options that are not part of the MainFrame. In this case, you may
need to gray out, disable, or implement new calls, based upon the
InternalFrame that is visible or has focus.
What you need to do (in the ideal), is to create the JMenuBar as a separate
class. You may want to make the class static (or a method static, as in a
singleton pattern), so that you can reuse the menu without a new
instantiation. You would also need to have a class that would implement the
behavior on the Events and listeners you use through mouse clicks and/or
keystrokes. This is a normal way of developing Swing applications.
I suggest that you consult with the Swing Tutorials on the javasoft site. I
am sure you can find adequate examples of what I am speaking of.
Good Luck!!
 

Re:Jmenubar on multiple frames

Dear Paul,
Thanks for ur suggestion and help, yes i tried with JDesktopPane and JLayeredPane to solve it but unable to do it..
I like ur suggestion to make seprate class for jmenu.....But why for their events......As I am bit new in Java.....(specially)
I tried to search google and google groups for old messages with keywords "Adding menubar on more than two frames", "sharing menubar" and i also tried to see in jbuilder and swing tutorial examples but everywhere they deal with Single Class of Jframe. Not with more than two Jframes....
...You help would be great support if you tell how and if possible with little example of both classes and how to use it...
Thankyou again for suggestion
Hussaan
"Paul Nichols \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"hussan" < XXXX@XXXXX.COM >wrote in message
news:42305e01$ XXXX@XXXXX.COM ...
>
>HI
>
>I am facing problem to set jmenubar on more than one frame.
>Is i have to replicate all code (and events) on other frame files (or
there is other technique).
>

Most people would use an MDI application in this scenario, so that the Top
level or MainFrame is the one to which the JMenuBar would be owned.

Of course, even then, you would want to provide (in the ideal world), some
level of abstraction. For instance, some JInternalFrames you display, might
need menu options that are not part of the MainFrame. In this case, you may
need to gray out, disable, or implement new calls, based upon the
InternalFrame that is visible or has focus.

What you need to do (in the ideal), is to create the JMenuBar as a separate
class. You may want to make the class static (or a method static, as in a
singleton pattern), so that you can reuse the menu without a new
instantiation. You would also need to have a class that would implement the
behavior on the Events and listeners you use through mouse clicks and/or
keystrokes. This is a normal way of developing Swing applications.

I suggest that you consult with the Swing Tutorials on the javasoft site. I
am sure you can find adequate examples of what I am speaking of.

Good Luck!!


 

{smallsort}

Re:Jmenubar on multiple frames

"Hussaan" < XXXX@XXXXX.COM >wrote in message
Quote

Dear Paul,

Thanks for ur suggestion and help, yes i tried with JDesktopPane and
JLayeredPane to solve it but unable to do it..

I like ur suggestion to make seprate class for jmenu.....But why for their
events......As I am bit new in Java.....(specially)

Look at these for examples.
examples.oreilly.com/jswing2/code/ (on line book).
www.javaolympus.com/J2SE/JFC/Swing/Swing.jsp (lots of tutorials)
www.onjava.com/pub/a/onjava/2004/03/10/blackmamba.html (on
line book excepts)
java.sun.com/docs/books/tutorial/uiswing/index.html
There is no quick and dirty examples that I could give you. You will need to
understand the entire model of Swing and the way it works, if you want to
develop "Swinging applications" (yes, pun intended)
Hope this helps ya.
Paul