Michail Petrov wrote:... when i compile it gives me error
what is the problem
Can you tell us what error you are getting? Once we know what error then we should have a better idea of how to fix it. Copy and paste the error that you see so we get all the information (the exact name and location of the error).
I see. Look at the API for javax.swing.JFrame. The add(...) methods expect Components. Your firmFrame is not a Component or a subclass of Component so it can't be added to the Frame. What you need to do is expose the JMenuBar from the firmFrame class so the mainFraim class has access to it. For example store the JMenuBar as a member variable, then provide a 'JMenuBar getMenuBar()' method which returns it.
Also, since you want to add a JMenuBar to the JFrame, I would suggest you not use JFrame#add(), but instead use JFrame#setJMenuBar().
Michail Petrov wrote:coud you give me simple code i can geht it i use the setJMenuBar but the result is the same
Well, I will give you some stock sample code so you can apply it to your application. Let's say I have a Name object that makes a firstName and a lastName. I then have a Person class that wants to print the firstName. The first thing to do would be to make the Name object. If Name looked the way firmFrame does in your application, then it might look like this:
And Person might try to do this:
If the goal is for Person to print Name's first name, well it won't work. I have to change Name so that the firstName becomes visible to Person. First I have to make a member variable in Name to store the firstName, then I have to make a method which returns that value.
Now Person can call Name's getFirstName() method in order to print it out:
Just to round things off, I will modify Name one more time, so that lastName gets the same treatment as firstName, just in case I want to print out lastName at some point as well:
Hopefully you will be able to see what you need to do and apply it to your application.