Hi,

I'm having troubles with my JMenuItems and Jframe. I want that when you click on a JMenuItem the previous JPanel dissapears and the one you clicked for at the JMenuItem will appear. Now, I don't really know how to accomplish this.

Someone said to me I should use the observer design pattern, but I don't know if this will work or not. I did read about the observer pattern and understand what is about. So can this pattern solve my pattern? And how?

Grtz

Hi,

I'm having troubles with my JMenuItems and Jframe. I want that when you click on a JMenuItem the previous JPanel dissapears and the one you clicked for at the JMenuItem will appear. Now, I don't really know how to accomplish this.

Someone said to me I should use the observer design pattern, but I don't know if this will work or not. I did read about the observer pattern and understand what is about. So can this pattern solve my pattern? And how?

Grtz

Use CardLayout or either add all your JPanel in your frame and setVisible false for all and use MenuListener to make the required JPanel visible

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.