I am new to Java. I have programming experience on other programming languages , especially in PowerBuilder. I am writing a Java application with many forms and reports. I want to have a menu common for all forms and reports (any window on my application).
I thought I could create a basic mainframe with the menu on it and the open any other window inside this main frame. I can't figure this out , only with internal frames but this is not what I want.
I made my JMenuBar
, I put it on JPanel
and then I put panel on a maximized JFrame
I called mainframe
. Any window from menu bar opens in front of mainframe
frame. When I click on mainframe
any open window goes back of course, focus is on the mainframe
.
I wrote a MouseListener
for panel which brings any open window toFront
except mainframe
of course. That seems to make the job but I have to write the same listener for the menu bar and this has the disadvantage of windows "flashing" any time they are coming to front.
My questions are:
- What is the way you work with menu bars?
- Do I have to put menu bar to any form I create?
- How can I have a main frame (maybe maximized) with the menu bar on it always on back and any other window opens in front of this frame?
What I really need is a main frame with menu for my application and everything happens inside this frame.