Hi, I nead to do some menu in gui Netbeans. I have got buttons, and a nead to change one JPanel in witch is some others components.
Could you help me how to change JPanels? or some another way to do menu? i'm not good at it :(

Recommended Answers

All 3 Replies

Use these classes:

JMenu
JMenuBar
JMenuItem

check the api for them.

The ideas is:
You create one JMenuBar.
You create some JMenus and you add them to the one JMenuBar.
You create some JMenuItems and you add them to your JMenus

Also there is this:
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html

Thanks, that I've got. But problem is, how to change space under menu.. I can make some JPanel form, but how to write to action(jMenu1ActionPerformed) to display some JPanel, and to klick to another menu button to display another one.. I can't do it...

I assume that you can add an actionlistener to the menuItem using the addActionListener method. Look the API. When the menu is selected the actionPerformed method of the ActionListener is automatically called.

I believe that there is a remove method that removes components from the JFrame. I have never used it before, but I believe that if you add a JPanel to the JFrame and then you call the remove method with argument the same JPanel, it will be removed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.